Skip to content

Commit

Permalink
feat : get bounds from map
Browse files Browse the repository at this point in the history
* add method `getBounds` in ios side
* change boundingWorldBox to bounds (mistake)
* change example
  • Loading branch information
liodali committed Dec 17, 2021
1 parent 9b46025 commit 823cd6e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class FlutterOsmView(

private fun getMapBounds(result: MethodChannel.Result) {
val bounds = map?.boundingBox ?: boundingWorldBox
result.success(boundingWorldBox.toHashMap())
result.success(bounds.toHashMap())
}


Expand Down
21 changes: 8 additions & 13 deletions example/lib/src/home/home_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _MainExampleState extends State<MainExample> with OSMMixinObserver {
});
controller.listenerRegionIsChanging.addListener(() async {
if (controller.listenerRegionIsChanging.value != null) {
print(controller.listenerRegionIsChanging.value);
print(controller.listenerRegionIsChanging.value);
}
});

Expand Down Expand Up @@ -144,6 +144,8 @@ class _MainExampleState extends State<MainExample> with OSMMixinObserver {
],
"line 2",
);
final bounds = await controller.bounds;
print(bounds.toString());
}

@override
Expand Down Expand Up @@ -200,8 +202,7 @@ class _MainExampleState extends State<MainExample> with OSMMixinObserver {
}),
IconButton(
onPressed: () async {
visibilityZoomNotifierActivation.value =
!visibilityZoomNotifierActivation.value;
visibilityZoomNotifierActivation.value = !visibilityZoomNotifierActivation.value;
zoomNotifierActivation.value = !zoomNotifierActivation.value;
},
icon: Icon(Icons.zoom_out_map),
Expand Down Expand Up @@ -233,10 +234,7 @@ class _MainExampleState extends State<MainExample> with OSMMixinObserver {
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircularProgressIndicator(),
Text("Map is Loading..")
],
children: [CircularProgressIndicator(), Text("Map is Loading..")],
),
),
initZoom: 8,
Expand Down Expand Up @@ -271,8 +269,7 @@ class _MainExampleState extends State<MainExample> with OSMMixinObserver {
"${geoPoint.toMap().toString()}",
),
action: SnackBarAction(
onPressed: () =>
ScaffoldMessenger.of(context).hideCurrentSnackBar(),
onPressed: () => ScaffoldMessenger.of(context).hideCurrentSnackBar(),
label: "hide",
),
),
Expand Down Expand Up @@ -356,8 +353,7 @@ class _MainExampleState extends State<MainExample> with OSMMixinObserver {
heroTag: "confirmAdvPicker",
onPressed: () async {
advPickerNotifierActivation.value = false;
GeoPoint p =
await controller.selectAdvancedPositionPicker();
GeoPoint p = await controller.selectAdvancedPositionPicker();
print(p);
},
),
Expand Down Expand Up @@ -542,8 +538,7 @@ class _MainExampleState extends State<MainExample> with OSMMixinObserver {
showMarkerOfPOI: false,
),
);
print(
"duration:${Duration(seconds: roadInformation.duration!.toInt()).inMinutes}");
print("duration:${Duration(seconds: roadInformation.duration!.toInt()).inMinutes}");
print("distance:${roadInformation.distance}Km");
});
} on RoadException catch (e) {
Expand Down
8 changes: 7 additions & 1 deletion ios/Classes/MyMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public class MyMapView: NSObject, FlutterPlatformView, CLLocationManagerDelegate
case "goto#position":
goToSpecificLocation(call: call, result: result)
break;
case "map#bounds":
getMapBounds(result:result)
break;
case "user#pickPosition":
//let frameV = UIView()
methodCall = call
Expand Down Expand Up @@ -254,7 +257,10 @@ public class MyMapView: NSObject, FlutterPlatformView, CLLocationManagerDelegate
}



private func getMapBounds(result: FlutterResult) {
let bounds = mapView.getBounds(width:mainView.bounds.width,height:mainView.bounds.height)
result(bounds)
}

private func setCameraAreaLimit(call: FlutterMethodCall) {
let bbox = call.arguments as! [Double]
Expand Down

0 comments on commit 823cd6e

Please sign in to comment.