How would one go about adding only the visible markers to the map. I basically want to have a list of markers, get the visible area of the map, and display only the markers that are within that box. I found that adding about 8300 markers was a bit too heavy...
How would I be able to get the corners of the visible portion of the map?
Interesting case. The map does filter out markers that aren't in view but we may need to add an API for getting the current bounding box from the controller to support this particular case so that you can filter the markers manually?
@johnpryan - just function to get the bounds. If there a way to get bounds of the map - these bounds can be send to the backend or whatever for the filrtering of the markers. (I have DB with the 25M markers and realtime connections and change)
sounds reasonable, we accept pull requests :)
@johnpryan @yostrokon Yes, it would be nice to get the bounds of the map. Is anyone willing to make a PR? I'm not sure where to start or how to implement it but maybe I could do it if you give me some ideas? Quite new to flutter though...
@vinicentus check the clip things in the source - no computer till end of the week to do things. But clip should provide bounds
@yostrokon I probably won't have the time to look at this right now so maybe you could take a look?
Hi @yostrokon
I couldn't find this clip things in the source? Could You help? thx!
I needed this tonight so put together quick PR: #99
This exposes bounds both via the MapController:
final LatLngBounds b = mapController.bounds;
and via the onPositionChanged callback:
new FlutterMap(
mapController: mapController,
options: new MapOptions(
onPositionChanged: (mp) => print(mp.bounds),
),
);
@xqwzts
if (options.onPositionChanged != null) {
options.onPositionChanged(new MapPosition(center: center, zoom: zoom));
}
what will happen when is a zoom only and position remains the same?
@yostrokon zooming triggers MapState.move() - which calls onPositionChanged(). So zooming and panning both trigger a position changed callback.
Thank you to everyone that contributed! Especially @xqwzts ;-)
Most helpful comment
I needed this tonight so put together quick PR: #99
This exposes bounds both via the
MapController:and via the
onPositionChangedcallback: