compileSdkVersion 29 buildToolsVersion '29.0.2' defaultConfig { minSdkVersion 19 targetSdkVersion 29 }
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.1.0'
public class CameraDemoActivity extends androidx.appcompat.app.AppCompatActivity
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.google.android.gms:play-services-basement:17.1.0' compileOptions {sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8} 工具转化完成后,某些使用switch-case选择语句会出现“case expressions must be constant expression”,switch中case必须为常量异常。此类方法需要转化成if-else形式,以此方式解决switch异常问题。
原代码示例:
switch (reason) { //REASON_GESTURE:手势 case OnCameraMoveStartedListener.REASON_GESTURE: currPolylineOptions.color(Color.BLUE); reasonText = "GESTURE"; break; //REASON_API_ANIMATION:api动画 case OnCameraMoveStartedListener.REASON_API_ANIMATION: currPolylineOptions.color(Color.RED); reasonText = "API_ANIMATION"; break; //REASON_DEVELOPER_ANIMATION:开发者动画 case OnCameraMoveStartedListener.REASON_DEVELOPER_ANIMATION: currPolylineOptions.color(Color.GREEN); reasonText = "DEVELOPER_ANIMATION"; break; }
修改后代码示例:
if (OnCameraMoveStartedListener.getREASON_GESTURE() == reason) { this.currPolylineOptions.color(Color.BLUE); reasonText = "GESTURE"; } else if (OnCameraMoveStartedListener.getREASON_API_ANIMATION() == reason) { this.currPolylineOptions.color(Color.RED); reasonText = "API_ANIMATION"; } else if (OnCameraMoveStartedListener.getREASON_DEVELOPER_ANIMATION() == reason) { this.currPolylineOptions.color(Color.GREEN); reasonText = "DEVELOPER_ANIMATION"; } else { reasonText = "UNKNOWN_REASON"; }
工具Add HMS API转换完成后,对于使用fragment展示的activity,我们提供配置ClassLoader(简单,仅需导入资源和修改配置文件)和手写代码(复杂,手工转换工作量大)两种手工转换方式来实现兼容Google API和HMS。
目前ClassLoader方案暂时不支持用户工程使用插件化或者热修复框架,不支持用户自定义ClassLoader,若您的应用存在上述情况,请使用手写代码方案。
更多关于ClassLoader方案的原理介绍,请参见XClassLoader方案基本原理介绍。
目前ClassLoader方式暂时不支持“Library”模式下的Add HMS API转换,在使用工具转换时请选择“App”模式。

自动转换完后请先在“Conversion”中处理好所有文件中Dummy状态相关接口的手工转换。
include ':xmsadapter:xmsaux', 'xmsadapter:xmsaux:xg', 'xmsadapter:xmsaux:xapi'
include ':xmsadapter:xmsaux', 'xmsadapter:xmsaux:xh', 'xmsadapter:xmsaux:xapi'
include ':xmsadapter:xmsaux', 'xmsadapter:xmsaux:xg', 'xmsadapter:xmsaux:xh', 'xmsadapter:xmsaux:xapi'
代码风味变体详情请参见Convertor工具实现生成多种变体APK。
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
} distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
android.enableD8=false android.enableD8.desugaring=false
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
GlobalEnvSetting.init(this,null);
XLoader.init(this);
}
} <application
android:name=".MyApp"
</application> Add HMS API场景下,Google API和HMS需要使用独立的layout资源文件,在各自的资源文件中<fragment/>class路径不同。
HMS layout资源文件中Fragment定义参考:
<fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.huawei.hms.maps.SupportMapFragment" />
Google API layout资源文件中Fragment定义参考:
<fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" />

layout资源文件都需要一式两份,HMS和Google API各一份,配合代码兼容跳转使用。
如果使用到了Fragment,可以在activity的onCreate()方法中通过if-else的方式一份代码同时兼容HMS和Google API。修改方式如下:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置gms资源文件 setContentView(R.layout.events_demo); mTapTextView = (TextView) findViewById(R.id.tap_text); mCameraTextView = (TextView) findViewById(R.id.camera_text); //在Activity的onCreate()方法中加载SupportMapFragment SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); //调用getMapAsync()来注册回调 mapFragment.getMapAsync(this); }
修改后代码示例:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //根据当前类型,选择根据G或者H创建 if (org.xms.g.utils.GlobalEnvSetting.isHms()) { createAsH(); } else { createAsG(); } } /** * HMS 创建流程 */ private void createAsH() { Log.d(TAG, "create as hms"); //设置hms资源文件 setContentView(R.layout.events_demo_hms); //初始化参数 initMember(); //根据id获取hms的fragment com.huawei.hms.maps.SupportMapFragment hMapFragment = (com.huawei.hms.maps.SupportMapFragment) this.getSupportFragmentManager().findFragmentById(R.id.map); //地图加载 hMapFragment.getMapAsync(this.getHInstanceOnMapReadyCallback()); } /** * GMS 创建流程 */ private void createAsG() { Log.d(TAG, "create as gms"); //设置gms资源文件 setContentView(R.layout.events_demo); //初始化参数 initMember(); //根据id获取gms的fragment com.google.android.gms.maps.SupportMapFragment gMapFragment = (com.google.android.gms.maps.SupportMapFragment) this.getSupportFragmentManager() .findFragmentById(R.id.map); //地图加载 gMapFragment.getMapAsync(this.getGInstanceOnMapReadyCallback()); } /** * 成员变量初始化,抽离成单独方法 */ private void initMember() { this.mTapTextView = (TextView) findViewById(R.id.tap_text); this.mCameraTextView = (TextView) findViewById(R.id.camera_text); }
工具完成转换后,如果发现在常量引用上有异常,可参考下方列表。googleMap中对常量采用直接使用的方式,但在Add HMS API场景下,常量使用Getter的方式来使用。如:
BitmapDescriptorFactory.HUE_ORANGE ,新的方式采用BitmapDescriptorFactory.getHUE_ORANGE(),Getter的方式来获取。
googleMap常量获取 | Add HMS API常量获取 |
|---|---|
import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_HYBRID(引用后直接使用) | ExtensionMap.getMAP_TYPE_NORMAL() |
BitmapDescriptorFactory.HUE_ORANGE | BitmapDescriptorFactory.getHUE_ORANGE() |
HuaweiMap.OnCameraMoveStartedListener.REASON_API_ANIMATION | HuaweiMap.OnCameraMoveStartedListener.getREASON_API_ANIMATION() |
googleMap常量获取 | To HMS API常量获取 |
|---|---|
import static com.google.android.gms.maps.GoogleMap.MAP_TYPE_HYBRID(引用后直接使用) | import static com.huawei.hms.maps.HuaweiMap.MAP_TYPE_HYBRID(引用后直接使用) |
Marker等部分Demo实现了OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener接口。其使用的Fragment支持Add HMS API场景的转换,在OnMapAndViewReadyListener类中进行,修改参考如下。
public OnMapAndViewReadyListener(
Fragment mapFragment, OnGlobalLayoutAndMapReadyListener devCallback) {} public class OnMapAndViewReadyListener implements OnGlobalLayoutListener, OnMapReadyCallback { /** * A listener that needs to wait for both the GoogleMap and the View to be initialized. */ public interface OnGlobalLayoutAndMapReadyListener { void onMapReady(ExtensionMap googleMap); } private final View mapView; private final OnGlobalLayoutAndMapReadyListener devCallback; private boolean isViewReady; private boolean isMapReady; private ExtensionMap googleMap; public OnMapAndViewReadyListener( Fragment mapFragment, OnGlobalLayoutAndMapReadyListener devCallback) { //hms处理 if (org.xms.g.utils.GlobalEnvSetting.isHms()) { com.huawei.hms.maps.SupportMapFragment hMapFragment = (com.huawei.hms.maps.SupportMapFragment) mapFragment; mapView = mapFragment.getView(); this.devCallback = devCallback; registerListeners(); // GoogleMap. Note if the GoogleMap is already ready it will still fire the callback later. hMapFragment.getMapAsync(this.getHInstanceOnMapReadyCallback()); } else { //gms 处理 com.google.android.gms.maps.SupportMapFragment gMapFragment = (com.google.android.gms.maps.SupportMapFragment) mapFragment; mapView = mapFragment.getView(); this.devCallback = devCallback; registerListeners(); // GoogleMap. Note if the GoogleMap is already ready it will still fire the callback later. gMapFragment.getMapAsync(this.getGInstanceOnMapReadyCallback()); } } private void registerListeners() { isViewReady = false; isMapReady = false; googleMap = null; // View layout. if ((mapView.getWidth() != 0) && (mapView.getHeight() != 0)) { // View has already completed layout. isViewReady = true; } else { // Map has not undergone layout, register a View observer. mapView.getViewTreeObserver().addOnGlobalLayoutListener(this); } } @Override public void onMapReady(ExtensionMap googleMap) { // NOTE: The GoogleMap API specifies the listener is removed just prior to invocation. this.googleMap = googleMap; isMapReady = true; fireCallbackIfReady(); } @SuppressWarnings("deprecation") // We use the new method when supported @SuppressLint("NewApi") // We check which build version we are using. @Override public void onGlobalLayout() { // Remove our listener. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { mapView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { mapView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } isViewReady = true; fireCallbackIfReady(); } private void fireCallbackIfReady() { if (isViewReady && isMapReady) { devCallback.onMapReady(googleMap); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //根据当前类型,选择根据G或者H创建 if (org.xms.g.utils.GlobalEnvSetting.isHms()) { createAsH(); } else { createAsG(); } } private void createAsH() { Log.d(TAG, "create as hms"); setContentView(R.layout.marker_demo_hms); //初始化参数 initMember(); //根据id获取hms的fragment com.huawei.hms.maps.SupportMapFragment hMapFragment = (com.huawei.hms.maps.SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); //创建OnMapAndViewReadyListener监听 new OnMapAndViewReadyListener(hMapFragment, this); } private void createAsG() { Log.d(TAG, "create as gms"); setContentView(R.layout.marker_demo); initMember(); com.google.android.gms.maps.SupportMapFragment hMapFragment = (com.google.android.gms.maps.SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); new OnMapAndViewReadyListener(hMapFragment, this); } private void initMember() { this.mTopText = (TextView) findViewById(R.id.top_text); this.mRotationBar = (SeekBar) findViewById(R.id.rotationSeekBar); this.mRotationBar.setMax(360); this.mRotationBar.setOnSeekBarChangeListener(this); this.mFlatBox = (CheckBox) findViewById(R.id.flat); this.mOptions = (RadioGroup) findViewById(R.id.custom_info_window_options); this.mOptions.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (MarkerDemoActivity.this.mLastSelectedMarker != null && MarkerDemoActivity.this.mLastSelectedMarker.isInfoWindowShown()) { // Refresh the info window when the info window's content has changed. MarkerDemoActivity.this.mLastSelectedMarker.showInfoWindow(); } } }); }
Add HMS API场景下,streeViewPanoramaFragment相对fragment的fragment在调用方式上略微有些不同,但基本思想都是根据系统类型做if-else处理。具体参考如下。
activity中onCreate修改示例。
原代码示例:
protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.street_view_panorama_basic_demo); SupportStreetViewPanoramaFragment streetViewPanoramaFragment = (SupportStreetViewPanoramaFragment) getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama); //设置一个回调对象,该对象将在GoogleMap实例准备好使用时被触发 streetViewPanoramaFragment.getStreetViewPanoramaAsync( new OnStreetViewPanoramaReadyCallback() { //当街景全景图准备好使用时调用 @Override public void onStreetViewPanoramaReady(StreetViewPanorama panorama) { // Only set the panorama to SYDNEY on startup (when no panoramas have been // loaded which is when the savedInstanceState is null). if (savedInstanceState == null) { panorama.setPosition(SYDNEY); } } }); }
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (org.xms.g.utils.GlobalEnvSetting.isHms()) { createAsH(savedInstanceState); } else { createAsG(savedInstanceState); } } private void createAsH(final Bundle savedInstanceState) { Log.d(TAG, "create as hms"); setContentView(R.layout.street_view_panorama_basic_demo_hms); initMember(); com.huawei.hms.maps.SupportStreetViewPanoramaFragment hStreetViewPanoramaFragment = (com.huawei.hms.maps.SupportStreetViewPanoramaFragment) getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama); hStreetViewPanoramaFragment.getStreetViewPanoramaAsync(panorama -> { // Only set the panorama to SYDNEY on startup (when no panoramas have been // loaded which is when the savedInstanceState is null). // HMS 转成org.xms org.xms.g.maps.StreetViewPanorama xmsStreetViewPanorama = new org.xms.g.maps.StreetViewPanorama(null, panorama); if (savedInstanceState == null) { xmsStreetViewPanorama.setPosition(SYDNEY); } }); } private void createAsG(final Bundle savedInstanceState) { Log.d(TAG, "create as gms"); setContentView(R.layout.street_view_panorama_basic_demo); initMember(); com.google.android.gms.maps.SupportStreetViewPanoramaFragment gStreetViewPanoramaFragment = (com.google.android.gms.maps.SupportStreetViewPanoramaFragment) getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama); gStreetViewPanoramaFragment.getStreetViewPanoramaAsync(panorama -> { // Only set the panorama to SYDNEY on startup (when no panoramas have been // loaded which is when the savedInstanceState is null). // HMS 转成org.xms org.xms.g.maps.StreetViewPanorama xmsStreetViewPanorama = new org.xms.g.maps.StreetViewPanorama(panorama, null); if (savedInstanceState == null) { xmsStreetViewPanorama.setPosition(SYDNEY); } }); } private void initMember() { }
streeViewPanoramaFragment的调用可以参考示例修改做业务的对应调整。
如果To HMS API场景使用Location Kit的接口,需要增加Location依赖。版本号“${version”请参见Location Kit的版本更新说明。
implementation 'com.huawei.hms:location:${version}' 如果使用Location功能,需要确保当前已获得位置权限。
获取位置权限示例代码:
/**
* only have permission of location,location function is enable
**/
if(enableMyLocation()){
getMyLocation();
setOnMyLocationChangeListener();
}
/**
* Request code for location permission request.
*
* @see #onRequestPermissionsResult(int, String[], int[])
*/
private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;
/**
* Enables the My Location layer if the fine location permission has been granted.
*/
private boolean enableMyLocation() {
//动态申请ACCESS_FINE_LOCATION权限
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// Permission to access the location is missing.
PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE,
Manifest.permission.ACCESS_FINE_LOCATION, true);
return false;
}else {
return true;
}
} 此接口可以使用Location Kit中的FusedLocationProviderClient.getLastLocation()方法替代。关于此接口的详细功能描述,可以参见Location Kit的FusedLocationProviderClient中getLastLocation()方法。
To HMS API示例代码:
// Current position.
private android.location.Location myLocation;
/**
* this is an Example:
* using location kit getLastLocation ,replace HuaweiMap.getMylocation() function
*/
private void getMyLocation(){
//调用getLastLocation()方法获取最后的已知位置
com.huawei.hmf.tasks.Task<android.location.Location> locationTask = LocationServices
.getFusedLocationProviderClient(this).getLastLocation();
//请求位置更新接口完成监听回调
locationTask.addOnCompleteListener(param0 -> {
if (locationTask != null) {
//获取经纬度
myLocation = locationTask.getResult();
double Lat = myLocation.getLatitude();
double Lng = myLocation.getLongitude();
Log.d(TAG, " Lat is : " + Lat +", Lng is : "+Lng);
}// 检查设备定位设置接口失败监听回调
}).addOnFailureListener(param0 -> Log.d(TAG,"lastLocation is error"));
} Add HMS API示例代码:
//current location private android.location.Location myLocation; /** * this is an Example: * using location kit getLastLocation ,replace HuaweiMap.getMylocation() function */ private void getMyLocation(){ //调用getLastLocation()方法获取最后的已知位置 org.xms.g.tasks.Task<android.location.Location> locationTask = LocationServices .getFusedLocationProviderClient(this).getLastLocation(); //请求位置更新接口完成监听回调 locationTask.addOnCompleteListener(param0 -> { if (locationTask != null) { //获取经纬度 myLocation = locationTask.getResult(); double Lat = myLocation.getLatitude(); double Lng = myLocation.getLongitude(); Log.d(TAG, " Lat is : " + Lat +", Lng is : "+Lng); }// 检查设备定位设置接口失败监听回调 }).addOnFailureListener(param0 -> Log.d(TAG,"lastLocation is error")); }
此接口可以使用Location Kit中的FusedLocationProviderClient.requestLocationUpdates(LocationRequest request, LocationCallback callback, Looper looper)方法替代。接口描述请参见FusedLocationProviderClient。
To HMS API示例代码:
/**
* this is an Example
* using location kit requestLocationUpdates(Request,LocationCallback,Looper) ,replace HuaweiMap.setOnMyLocationChangeListener()
*/
private void setOnMyLocationChangeListener(){
// When you construct request parameters, please refer to the development guide of the Location Kit.
//设置持续定位请求参数
com.huawei.hms.location.LocationRequest request = new com.huawei.hms.location.LocationRequest();
//设置位置更新的时间(单位为毫秒)
request.setInterval(2000);
//调用requestLocationUpdates()进行持续定位
LocationServices
.getFusedLocationProviderClient(this).requestLocationUpdates(request, new LocationCallback() {
@Override
public void onLocationResult( com.huawei.hms.location.LocationResult locationResult) {
if (locationResult != null) {
//处理位置回调结果
List<Location> locations = locationResult.getLocations();
if (!locations.isEmpty()) {
for (Location location : locations) {
Log.i(TAG,
"onLocationResult location[Longitude,Latitude,Accuracy]:"
+ location.getLongitude() + "," + location.getLatitude() + ","
+ location.getAccuracy());
}
}
}
}
@Override
public void onLocationAvailability(LocationAvailability locationAvailability) {
if (locationAvailability != null) {
//定位是否可用
boolean flag = locationAvailability.isLocationAvailable();
Log.i(TAG, "onLocationAvailability isLocationAvailable:" + flag);
}
}
}, android.os.Looper.myLooper()).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void param0) {
Log.d(TAG,"onSuccess.....");
}
});
} Add HMS API示例代码:
/**
* this is an Example
* using location kit requestLocationUpdates(Request,LocationCallback,Looper) ,replace HuaweiMap.setOnMyLocationChangeListener()
*/
private void setOnMyLocationChangeListener(){
//Construct request param,you can read location kit developer guide for details
org.xms.g.location.LocationRequest request = new org.xms.g.location.LocationRequest();
/设置位置更新的间隔(单位为毫秒)
request.setInterval(2000);
//调用requestLocationUpdates()进行持续定位
LocationServices
.getFusedLocationProviderClient(this).requestLocationUpdates(request, new LocationCallback() {
@Override
public void onLocationResult( org.xms.g.location.LocationResult locationResult) {
if (locationResult != null) {
// 处理位置回调结果
List<Location> locations = locationResult.getLocations();
if (!locations.isEmpty()) {
for (Location location : locations) {
Log.i(TAG,
"onLocationResult location[Longitude,Latitude,Accuracy]:"
+ location.getLongitude() + "," + location.getLatitude() + ","
+ location.getAccuracy());
}
}
}
}
@Override
public void onLocationAvailability(LocationAvailability locationAvailability) {
if (locationAvailability != null) {
//定位是否可用
boolean flag = locationAvailability.isLocationAvailable();
Log.i(TAG, "onLocationAvailability isLocationAvailable:" + flag);
}
}
}, android.os.Looper.myLooper()).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void param0) {
Log.d(TAG,"onSuccess.....");
}
});
} 此方法可以使用setOnCameraMoveStartedListener、setOnCameraMoveListener、setOnCameraIdleListener方法替代,实现moveCamera事件的监听。
示例代码:
/**
* this is an Example
* using setOnCameraMoveStartedListener、setOnCameraMoveListener、setOnCameraIdleListener to
* replace to HuaweiMap.setOnCameraChangeListener.
*/
private void setOnCameraChangeListener() {
Log.d(TAG, " start addMoveListener...");
//设置一个回调,当摄像机开始移动时调用
this.mMap.setOnCameraMoveStartedListener(i -> Log.d(TAG," start camera move..."));
//设置在摄像机处于运动状态时反复调用的回调函数
this.mMap.setOnCameraMoveListener(() -> Log.d(TAG," camera moving..."));
//设置相机移动结束时调用的回调
this.mMap.setOnCameraIdleListener(() -> {
Log.d(TAG," idle camera move... ");
});
} 地图样式设置(包括retro、night、grayscale、simple样式 )需要加载JSON资源文件,HuaweiMap与GoogleMap使用的JSON文件格式上有差异,导致不能共用一份JSON资源文件。需要在业务代码层面做兼容适配。HuaweiMap地图样式JSON文件下载链接。


private void setSelectedStyle() {
MapStyleOptions style;
switch (this.mSelectedStyleId) {
case R.string.style_label_retro:
// Sets the retro style via raw resource JSON.
if(GlobalEnvSetting.isHms()){
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro_hms);
}else{
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro);
}
break;
case R.string.style_label_night:
// Sets the night style via raw resource JSON.
if(GlobalEnvSetting.isHms()){
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night_hms);
}else{
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night);
}
break;
case R.string.style_label_grayscale:
// Sets the grayscale style via raw resource JSON.
if(GlobalEnvSetting.isHms()){
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale_hms);
}else{
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale);
}
break;
case R.string.style_label_no_pois_no_transit:
// Sets the no POIs or transit style via JSON string.
style = new MapStyleOptions("[" + " {" + " \"featureType\":\"poi.business\","
+ " \"elementType\":\"all\"," + " \"stylers\":[" + " {"
+ " \"visibility\":\"off\"" + " }" + " ]" + " }," + " {"
+ " \"featureType\":\"transit\"," + " \"elementType\":\"all\"," + " \"stylers\":["
+ " {" + " \"visibility\":\"off\"" + " }" + " ]" + " }" + "]");
break;
case R.string.style_label_default:
// Removes previously set style, by setting it to null.
style = null;
break;
default:
return;
}
//设置基础地图风格,设置为null表示清除先前的自定义风格
this.mMap.setMapStyle(style);
}