MapscloudMap开发文档
项目配置
1. app模块的build.gradle文件中添加ndk配置,如下
android {
/** 其它配置 **/
defaultConfig {
/** 其它配置 **/
ndk {
abiFilters "armeabi", "armeabi-v7a"
}
}
}
如果没有配置,将在调用 Mapbox.getInstance(context, "你申请的key");
时,报如下异常:
java.lang.UnsatisfiedLinkError: No implementation found for void
com.mapbox.mapboxsdk.net.NativeConnectivityListener.initialize()
(tried Java_com_mapbox_mapboxsdk_net_NativeConnectivityListener_initialize and
Java_com_mapbox_mapboxsdk_net_NativeConnectivityListener_initialize__)
2. 读写权限非常重要,项目中涉及很多本地.db文件的读写
3. application 必须为 BasicApplication
或者 其子类
项目中很多地方会使用 BasicApplication
中的单例对象,例如:
String rootPath = DataUtils.getAreaDataDbRootPath(BasicApplication.getInstance().getApplication());
4. assets目录下配置 model_setting.xml
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<model-group>
<model
id="1"
name="记录:涂鸦"
class="com.starmap.app.model.graffiti.GraffitRecordMode"
enable="true" >
</model>
<model
id="2"
name="搜索"
class="com.mapscloud.search.SearchModel"
enable="true" >
</model>
<model
id="3"
name="周边"
class="com.mapscloud.surround.SurroundModel"
enable="true" >
</model>
<model
id="4"
name="罗盘"
class="com.mapscloud.compass.CompassModel"
enable="true" >
</model>
<model
id="5"
name="书签"
class="com.starmap.app.model.bookmark.BookMarkModel"
enable="true" >
</model>
<model
id="6"
name="方位角"
class="com.mapscloud.measuretools.azimuth.AzimuthModel"
enable="true" >
</model>
<model
id="7"
name="剖面测量"
class="com.mapscloud.measuretools.profile.ProfileModel"
enable="true" >
</model>
<model
id="8"
name="测面积"
class="com.mapscloud.measuretools.areaanddistance.MeasureAreaModel"
enable="true" >
</model>
<model
id="9"
name="测距"
class="com.mapscloud.measuretools.areaanddistance.MeasureDistanceModel"
enable="true" >
</model>
<model
id="10"
name="路标指引"
class="com.app.lib.signpost.guide.RoadSignGuideModel"
enable="true" >
</model>
<model
id="11"
name="轨迹导航"
class="com.starmap.app.model.navigation.NavigationModel"
enable="true" >
</model>
<model
id="12"
name="路标"
class="com.app.lib.signpost.RoadSignModel"
enable="true" >
</model>
<model
id="13"
name="路径绘制"
class="com.app.lib.signpost.roadpathdraw.RoadDrawModel"
enable="true" >
</model>
<model
id="14"
name="轨迹记录"
class="com.starmap.app.model.maprecord.MapLoggerRecord"
enable="true" >
</model>
<model
id="15"
name="分幅图"
class="com.starmap.app.model.thememap.ThemeModel"
enable="true" >
</model>
<model
id="16"
name="专题信息"
class="com.dtt.themeinfolibrary.MilitaryModel"
enable="true" >
</model>
<model
id="17"
name="兵要"
class="com.dtt.monographicinfo.model.MonographicInfoModel"
enable="true" >
</model>
<model
id="18"
name="北斗通信"
class="com.starmap.bdmessage.BeiDouMessageLibrary"
enable="true" >
</model>
<model
id="19"
name="街景"
class="com.starmap.streetmap.streetmaplibrary.StreetMapModel"
enable="true" >
</model>
<model
id="20"
name="全球轨迹导航"
class="com.mapscloud.navigation.OsmNavigationModel"
enable="true" >
</model>
</model-group>
5. 兼容android 9 明文传输(支持http请求,默认只支持https方式的请求)
android 9 之上可能地图准备完成,只能看到一层灰色的背景。
更改 AndroidManifest 的 application 标签下的配置。
-
添加 networkSecurityConfig(网络安全配置)。
android:networkSecurityConfig="@xml/network_security_config"
-
res/xml/下新建network_security_config.xml, 文件内容如下:
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <base-config cleartextTrafficPermitted="true" /> </network-security-config>
6. minSdk
Error: Static interface methods are only supported starting with Android N (–min-api 24): com.mapbox.geojson.Geometry com.mapbox.geojson.Geometry.fromJson(java.lang.String)