Last Updated on : 2024-04-28 06:07:47download
The Maps Service UI BizBundle supports Amap and Google Maps with the following features:
Add the following dependencies to the file build.gradle of module:
Support AutoNavi only:
 
 dependencies {
     api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:${biz_bom_version}")
     implementation 'com.thingclips.smart:thingsmart-bizbundle-map_amap'
     implementation 'com.thingclips.smart:thingsmart-bizbundle-location_amap'
     api "com.thingclips.smart:thingsmart:${sdk_version}}"
 }
 
 
Support Google Maps only:
 
 dependencies {
     api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:${biz_bom_version}")
    implementation 'com.thingclips.smart:thingsmart-bizbundle-map_google'
    implementation 'com.thingclips.smart:thingsmart-bizbundle-location_google'
     api "com.thingclips.smart:thingsmart:${sdk_version}}"
 }
 
 
For more information, see Request AutoNavi Key and Apply for Google Map Android API Key.
Add the following key information to the resource file res:
<string name="amapKey">AutoNavi Key</string>
<string name="google_maps_key">Google Maps Key</string>
In the AndroidManifest file, add android:allowNativeHeapPointerTagging="false" under the application tag.
    <application
        android:allowNativeHeapPointerTagging="false"
       >
    </application>
Accesses the AutoNavi service:
public static final int MAP_RESULT_OK = 10001;
UrlRouter.execute(UrlRouter.makeBuilder(mContext, "map_location_setting", null, MAP_RESULT_OK));
Receives returned data:
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
	super.onActivityResult(requestCode, resultCode, data);
	switch (resultCode) {
		case MAP_RESULT_OK: {
			if (null != data) {
				double lat = data.getDoubleExtra("lat", 0);
				double lng = data.getDoubleExtra("lng", 0);
				String mCountry = data.getStringExtra("country");
				String mProvince = data.getStringExtra("province");
				String mCity = data.getStringExtra("city");
				String mAddress = data.getStringExtra("address");
			}
		}
		break;
		default:
			break;
	}
}
Accesses the Google Maps service:
// Accesses the geofencing feature of Google Maps.
UrlRouter.execute(UrlRouter.makeBuilder(mContext, "map_geofence", bundle, GEOSELECT_REQUEST_CORE));
Receives returned data:
// Receives returned data.
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
	super.onActivityResult(requestCode, resultCode, data);
	switch (resultCode) {
		case GEOSELECT_REQUEST_CORE: {
			if(null != data) {
				double lat = data.getDoubleExtra("lat", 0);
				double lng = data.getDoubleExtra("lng", 0);
				int mRadius = data.getIntExtra("radius", 0);
				String mAddress = TextUtils.isEmpty(data.getStringExtra("address")) ? "" : data.getStringExtra("address");
			}
		}
		break;
		default:
			break;
	}
}
Enables the location feature:
LocationService locationService = MicroServiceManager.getInstance().findServiceByInterface(LocationService.class.getName());
if (locationService!=null) {
	locationService.updateLocation();
}
Returns the location information:
LocationService locationService = MicroServiceManager.getInstance().findServiceByInterface(LocationService.class.getName());
if (locationService!=null) {
	LocationBean location = locationService.getLocation();
	if (location != null) {
		//...
	}
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback