Skip to content

Commit

Permalink
add zoom function
Browse files Browse the repository at this point in the history
  • Loading branch information
huangjiahong committed Sep 9, 2021
1 parent b3f765c commit 4423951
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 1 deletion.
143 changes: 142 additions & 1 deletion android/src/main/java/com/imfunc/flutter_minemap/unil/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,149 @@ public static class ViewType {
* 地图状态
*/
public static class FMMMapStateMethodId {
public static final String sMapSetStyleMethod = "flutter_minemap/map/setStyleJson";
/// 设置地图中心点
public static final String sMapSetCenterMethod = "flutter_minemap/map/setCenter";

/// 获取地图中心点
public static final String sMapGetCenterMethod = "flutter_minemap/map/getCenter";

/// 设置地图缩放级别
public static final String sMapSetZoomMethod = "flutter_minemap/map/setZoom";

/// 获取地图缩放级别
public static final String sMapGetZoomMethod = "flutter_minemap/map/getZoom";

/// 设置地图最小缩放级别
public static final String sMapSetMinZoomPreferenceMethod = "flutter_minemap/map/setMinZoomPreference";

/// 获取地图最小缩放级别
public static final String sMapGetMinZoomLevelMethod = "flutter_minemap/map/getMinZoomLevel";

/// 设置地图最大缩放级别
public static final String sMapSetMaxZoomPreferenceMethod = "flutter_minemap/map/setMaxZoomPreference";

/// 获取地图最大缩放级别
public static final String sMapGetMaxZoomLevelMethod = "flutter_minemap/map/getMaxZoomLevel";

/// 设置地图俯仰角度
public static final String sMapSetTiltMethod = "flutter_minemap/map/setTilt";

/// 获取地图俯仰角度
public static final String sMapGetTiltMethod = "flutter_minemap/map/getTilt";

/// 设置地图旋转角度
public static final String sMapSetBearingMethod = "flutter_minemap/map/setBearing";

/// 获取地图旋转角度
public static final String sMapGetBearingMethod = "flutter_minemap/map/getBearing";

/// 设置是否开启wmts模式
public static final String sMapSetWmtsEnabledMethod = "flutter_minemap/map/setWmtsEnabled";

/// 获取是否开启wmts模式
public static final String sMapGetWmtsEnabledMethod = "flutter_minemap/map/getWmtsEnabled";

/// 设置图层跨级访问方式
public static final String sMapSetOdevityMethod = "flutter_minemap/map/setOdevity";

/// 设置路况跨级访问方式
public static final String sMapSetOdevityForTrafficMethod = "flutter_minemap/map/setOdevityForTraffic";

/// 获取图层跨级访问方式
public static final String sMapGetOdevityMethod = "flutter_minemap/map/getOdevity";

/// 获取路况跨级访问方式
public static final String sMapGetOdevityForTrafficMethod = "flutter_minemap/map/getOdevityForTraffic";

/// 设置地图样式
public static final String sMapSetStyleMethod = "flutter_minemap/map/setStyleJson";

/// 设置是否显示路况
public static final String sMapSetTrafficShowMethod = "flutter_minemap/map/setTrafficShow";

/// 设置路况刷新的时间间隔
public static final String sMapSetTrafficRoteMethod = "flutter_minemap/map/setTrafficRote";

/// 重新刷新路况
public static final String sMapUpDataTrafficMethod = "flutter_minemap/map/upDataTraffic";

/// 路况显示范围指定
public static final String sMapSetAreaTrafficMethod = "flutter_minemap/map/setAreaTraffic";

/// 是否开启动态持续刷新
public static final String sMapSetRepaintMethod = "flutter_minemap/map/setRepaint";

/// 设置是否显示地图调试信息
public static final String sMapSetDebugActiveMethod = "flutter_minemap/map/setDebugActive";

/// 获取当前是否显示地图调试信息
public static final String sMapIsDebugActiveMethod = "flutter_minemap/map/isDebugActive";

/// 将地图重置为朝北
public static final String sMapResetNorthMethod = "flutter_minemap/map/resetNorth";

/// 取消正在进行的动画
public static final String sMapCancelTransitionsMethod = "flutter_minemap/map/cancelTransitions";

/// 根据CameraUpdate参数移动相机。
public static final String sMapMoveCameraMethod = "flutter_minemap/map/moveCamera";

/// 以默认持续时间逐渐移动相机, 缩放将不会受到影响, 除非在CameraUpdate中指定。
public static final String sMapEaseCameraMethod = "flutter_minemap/map/easeCamera";

/// 可视区域动画,是指从当前可视区域转换到一个指定位置的可视区域的过程。
public static final String sMapAnimateCameraMethod = "flutter_minemap/map/animateCamera";

/// 获取相机的当前位置.返回的CameraPosition是当前位置的快照, 在相机移动时不会自动更新。
public static final String sMapGetCameraPositionMethod = "flutter_minemap/map/getCameraPosition";

/// 设置约束地图界限
public static final String sMapSetLatLngBoundsForCameraTargetMethod = "flutter_minemap/map/setLatLngBoundsForCameraTarget";

/// 根据地图界限和边距获取相机位置
public static final String sMapGetCameraForLatLngBoundsMethod = "flutter_minemap/map/getCameraForLatLngBounds";

/// 设置地图边距
public static final String sMapSetPaddingMethod = "flutter_minemap/map/setPadding";

/// 获取地图边距
public static final String sMapGetPaddingMethod = "flutter_minemap/map/getPadding";

/// 是否允许多个信息视窗
public static final String sMapSetMultipleInfoWindowsMethod = "flutter_minemap/map/setMultipleInfoWindows";

/// 添加当前地图样式中使用的图像
public static final String sMapAddImageMethod = "flutter_minemap/map/addImage";

/// 批量添加当前地图样式中使用的图像
public static final String sMapAddImagesMethod = "flutter_minemap/map/addImages";

/// 从当前地图的样式中删除图像
public static final String sMapRemoveImageMethod = "flutter_minemap/map/removeImage";

/// 从当前地图的样式中批量删除图像
public static final String sMapRemoveImagesMethod = "flutter_minemap/map/removeImages";

/// 从当前地图的样式中删除所有图像
public static final String sMapRemoveImagesAllMethod = "flutter_minemap/map/removeImagesAll";

/// 根据图像名称ID获取当前地图的样式中的图像对象
public static final String sMapGetImageMethod = "flutter_minemap/map/getImage";

/// 离线数据更新,离线地图包变更后必须调用此方法。
public static final String sMapOfflineDataUpdateMethod = "flutter_minemap/map/offlineDataUpdate";

/// 是否显示水纹
public static final String sMapSetFillWaterEnabledMethod = "flutter_minemap/map/setFillWaterEnabled";

/// 设置是否联网,如果为false,则使用纯离线地图。
public static final String sMapSetConnectedMethod = "flutter_minemap/map/setConnected";

/// 获取屏幕上1像素点对应的地图上距离长度,单位米
public static final String sMapGetScalePerPixelMethod = "flutter_minemap/map/getScalePerPixel";

/// 设置事件自动刷新
public static final String sMapUpDataTrafficEventMethod = "flutter_minemap/map/upDataTrafficEvent";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,48 @@ public void dispatchMethodHandler(Context context, MethodCall call,
switch (methodId) {
case Constants.FMMMapStateMethodId.sMapSetStyleMethod:
case Constants.FMMMapStateMethodId.sMapSetCenterMethod:
case Constants.FMMMapStateMethodId.sMapGetCenterMethod:
case Constants.FMMMapStateMethodId.sMapSetZoomMethod:
case Constants.FMMMapStateMethodId.sMapGetZoomMethod:
case Constants.FMMMapStateMethodId.sMapSetMinZoomPreferenceMethod:
case Constants.FMMMapStateMethodId.sMapGetMinZoomLevelMethod:
case Constants.FMMMapStateMethodId.sMapSetMaxZoomPreferenceMethod:
case Constants.FMMMapStateMethodId.sMapGetMaxZoomLevelMethod:
case Constants.FMMMapStateMethodId.sMapSetTiltMethod:
case Constants.FMMMapStateMethodId.sMapGetTiltMethod:
case Constants.FMMMapStateMethodId.sMapSetBearingMethod:
case Constants.FMMMapStateMethodId.sMapGetBearingMethod:
case Constants.FMMMapStateMethodId.sMapSetWmtsEnabledMethod:
case Constants.FMMMapStateMethodId.sMapGetWmtsEnabledMethod:
case Constants.FMMMapStateMethodId.sMapSetOdevityMethod:
case Constants.FMMMapStateMethodId.sMapSetOdevityForTrafficMethod:
case Constants.FMMMapStateMethodId.sMapGetOdevityMethod:
case Constants.FMMMapStateMethodId.sMapGetOdevityForTrafficMethod:
case Constants.FMMMapStateMethodId.sMapSetTrafficShowMethod:
case Constants.FMMMapStateMethodId.sMapSetTrafficRoteMethod:
case Constants.FMMMapStateMethodId.sMapUpDataTrafficMethod:
case Constants.FMMMapStateMethodId.sMapSetAreaTrafficMethod:
case Constants.FMMMapStateMethodId.sMapSetRepaintMethod:
case Constants.FMMMapStateMethodId.sMapSetDebugActiveMethod:
case Constants.FMMMapStateMethodId.sMapIsDebugActiveMethod:
case Constants.FMMMapStateMethodId.sMapResetNorthMethod:
case Constants.FMMMapStateMethodId.sMapCancelTransitionsMethod:
case Constants.FMMMapStateMethodId.sMapMoveCameraMethod:
case Constants.FMMMapStateMethodId.sMapEaseCameraMethod:
case Constants.FMMMapStateMethodId.sMapAnimateCameraMethod:
case Constants.FMMMapStateMethodId.sMapGetCameraPositionMethod:
case Constants.FMMMapStateMethodId.sMapSetLatLngBoundsForCameraTargetMethod:
case Constants.FMMMapStateMethodId.sMapGetCameraForLatLngBoundsMethod:
case Constants.FMMMapStateMethodId.sMapSetPaddingMethod:
case Constants.FMMMapStateMethodId.sMapGetPaddingMethod:
case Constants.FMMMapStateMethodId.sMapSetMultipleInfoWindowsMethod:
case Constants.FMMMapStateMethodId.sMapAddImageMethod:
case Constants.FMMMapStateMethodId.sMapAddImagesMethod:
case Constants.FMMMapStateMethodId.sMapRemoveImageMethod:
case Constants.FMMMapStateMethodId.sMapRemoveImagesMethod:
case Constants.FMMMapStateMethodId.sMapRemoveImagesAllMethod:
case Constants.FMMMapStateMethodId.sMapGetImageMethod:
case Constants.FMMMapStateMethodId.sMapOfflineDataUpdateMethod:
mMapHandler = mMapHandlerHashMap.get(Constants.MMapHandlerType.MAP_STATE);
break;
case Constants.FMMClusterLayerMethodId.sMapAddClusterLayerMethod:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,59 @@ public void handlerMethodCallResult(Context context, MethodCall call, MethodChan
case Constants.FMMMapStateMethodId.sMapSetCenterMethod:
setCenter(call, result);
break;
case Constants.FMMMapStateMethodId.sMapSetZoomMethod:
setZoom(call, result);
break;
case Constants.FMMMapStateMethodId.sMapSetMinZoomPreferenceMethod:
setMinZoom(call, result);
break;
case Constants.FMMMapStateMethodId.sMapSetMaxZoomPreferenceMethod:
setMaxZoom(call, result);
break;
default:
break;
}
}

/**
*
* @param call
* @param result
*/
private void setMaxZoom(MethodCall call, MethodChannel.Result result) {
Integer zoom = FMMMapConveter.toInt(call.arguments);
if (zoom != null) {
mMapController.setMaxZoomLevel(zoom);
result.success(true);
}
}

/**
*
* @param call
* @param result
*/
private void setMinZoom(MethodCall call, MethodChannel.Result result) {
Integer zoom = FMMMapConveter.toInt(call.arguments);
if (zoom != null) {
mMapController.setMinZoomLevel(zoom);
result.success(true);
}
}

/**
*
* @param call
* @param result
*/
private void setZoom(MethodCall call, MethodChannel.Result result) {
Integer zoom = FMMMapConveter.toInt(call.arguments);
if (zoom != null) {
mMapController.setZoomLevel(zoom);
result.success(true);
}
}

/**
* @param call
* @param result
Expand Down

0 comments on commit 4423951

Please sign in to comment.