setCustomMapStyleWithOptionPath method

Future<bool> setCustomMapStyleWithOptionPath (
  1. {@required BMFCustomMapStyleOption customMapStyleOption,
  2. @required void preload(
    1. String path
    ),
  3. @required void success(
    1. String path
    ),
  4. @required void error(
    1. int errorCode,
    2. String path
    )}
)

设置个性化地图样式路径,仅影响当前mapView对象,需在对象创建后调用

在线个性化样式加载状态回调接口。

在线个性化样式创建地址:http://lbsyun.baidu.com/apiconsole/custommap

调用该接口加载个性化样式的默认策略为:

1、优先通过BMFCustomMapStyleOption配置的个性化样式ID,加载在线个性化样式;

2、如果配置的个性化样式ID无效或在线个性化样式请求失败,则加载本地缓存的最新一次请求成功的在线个性化样式;

3、如果本地缓存中没有最新一次请求成功的在线个性化样式,则通过BMFCustomMapStyleOption中配置的本地离线样式路径加载本地样式;

4、如果以上样式加载都失败,则显示普通地图样式。

BMFCustomMapStyleOption customMapStyleOption 在线个性化样式配置选项

preLoad 当预加载成功时会执行的block对象,path:本地缓存的最新一次请求成功的在线个性化样式路径

success 当加载成功时会执行的block对象,path:请求成功的在线个性化样式路径

error 当加载未成功时会执行的block对象,error:失败错误信息,path:失败后根据策略加载的个性化样式路径(路径可能会为nil)

bool 成功返回true 失败false

Implementation

Future<bool> setCustomMapStyleWithOptionPath(
    {@required BMFCustomMapStyleOption customMapStyleOption,
    @required void Function(String path) preload,
    @required void Function(String path) success,
    @required void Function(int errorCode, String path) error}) async {
  return await BMFMapDispatcherFactory.instance
      .getMapStateDispatcher()
      .setCustomMapStyleWithOptionDispatch(
          _mapChannel, customMapStyleOption, preload, success, error);
}