Open noorbakerally opened 2 years ago
This is not yet implemented in this plugin, but the functionality exists in the underlying MapLibre SDKs. (Also see https://github.com/flutter-mapbox-gl/maps/issues/908)
It should be relatively straightforward to implement this, a PR for this would be very welcome.
Hi, I can try to work on this. Which file should I try adding the scale to https://docs.maptiler.com/maplibre-gl-js/markers-and-controls/ - may help
@rohanshankar Sorry, I mislabeled this issue, since this is a bit more involved and probably not really suitable for a first contribution.
@m0nac0 in our project, we reached a point where we are required to implement this before delivering, can you provide some general/brief instructions for implementing this, before us diving into the plugin.
after looking at maplibre-gl-native, looks like the ScaleBar is implemented on ios only, I may be wrong but it looks like a hard task, I hope @m0nac0 can help. Since he is not active since december, i suggest you to ask the maplibre-gl-native team if it is possible at the current state of the library
@mariusvn Thanks for your advice, just a question, is there a different simpler way, like for example, without diving into the plugin, having a widget, the map scale, that is an overlay on the map. The widget will say have a width of Apx
, we only need a way to tell us how much Apx
represents on the map in terms of say meters, having this solve our problem, then we just have a listener that reacts to map zoom to update the map scale label.
Well i think you can do that with the controller's getMetersPerPixelAtLatitude
method
If you really want the widget to update only when the camera moves, you'll need to update this function in controller.dart:90
in the library to add a public callback:
_mapboxGlPlatform.onCameraMovePlatform.add((cameraPosition) {
_cameraPosition = cameraPosition;
notifyListeners();
});
We should actually add an event in the controller that says when the camera start moving
You can also use the isCameraMoving
boolean to check that but it will need a continuous check but it would not need a library edit.
Hello, I am also interested by a scale :) I don't know if this is still on the plan ? For now I'll try to do something with getMetersPerPixelAtLatitude.
I'm sorry to ask this here but cannot find this in the documentation, How to add a Map scale to a map that automatically updates based on the zoom level?