更新时间:2024-04-01 06:26:39下载pdf
涂鸦地图服务 UI 业务包主要包含高德地图和 Google 地图的相关功能。包括:
在工程 Module 的 build.gradle
添加配置:
只包括高德地图的配置:
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}}"
}
只包含 Google 地图配置:
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}}"
}
步骤详情,请参考 申请高德地图 key 和 申请 Google 地图安卓 API 密钥。
在 res
资源文件中添加您申请到的地图服务 Key:
<string name="amapKey">高德地图 Key</string>
<string name="google_maps_key">Google 地图 Key</string>
在 AndroidManifest
文件中,application
标签下新增 android:allowNativeHeapPointerTagging="false"
。
<application
android:allowNativeHeapPointerTagging="false"
>
</application>
进入高德地图:
public static final int MAP_RESULT_OK = 10001;
UrlRouter.execute(UrlRouter.makeBuilder(LocationActivity.this, "map_location_setting", bundle, MAP_RESULT_OK));
接收返回数据:
@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;
}
}
进入 Google 地图:
//进入 Google 地理围栏
UrlRouter.execute(UrlRouter.makeBuilder(mContext, "map_geofence", bundle, GEOSELECT_REQUEST_CORE));
接收返回数据:
//接收返回数据
@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;
}
}
唤起定位:
LocationService locationService = MicroServiceManager.getInstance().findServiceByInterface(LocationService.class.getName());
if (locationService!=null) {
locationService.updateLocation();
}
获取定位信息:
LocationService locationService = MicroServiceManager.getInstance().findServiceByInterface(LocationService.class.getName());
if (locationService!=null) {
LocationBean location = locationService.getLocation();
if (location != null) {
//……
}
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈