osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

Zoom to bounding box and restrict

Open chitgoks opened this issue 3 years ago • 9 comments

Is this feature available perhaps? I wish to zoom to a country bounding box and not let the user zoom out. Android library has

map.zoomToBoundingBox(getCountryBoundingBox(), false) map.setScrollableAreaLimitDouble(getCountryBoundingBox())

Perhaps available in this flutter lib?

chitgoks avatar Jul 14 '21 11:07 chitgoks

zoom with bounding box is not available in the plugin but i will add this feature in init configuration and in separate method

liodali avatar Jul 14 '21 12:07 liodali

i will publish new version 0.8.2 that contain set camera area limit of the map i added new attribute areaLimit in MapController to limit area when map initialize and i create 2 other method limitArea and removeLimitArea after init of the map

liodali avatar Jul 22 '21 22:07 liodali

for ios i will added in next version

liodali avatar Jul 22 '21 22:07 liodali

new version 0.8.2 was published now and also i will add zoomBoundingBox soon

liodali avatar Jul 22 '21 22:07 liodali

thank you

chitgoks avatar Jul 22 '21 23:07 chitgoks

i will keep this issue open until i finish all the feature in android/ios/web

liodali avatar Jul 23 '21 00:07 liodali

Hey! With limitArea you have opened up new possibilities. Could you explain more how do we get the east west north south attributes and use it to fit a certain portion of the map in screen ? Do we calculate from the geopoint ?

jesussmile avatar Jul 27 '21 02:07 jesussmile

the east west north south are 2 geoPoint = (south,west) are min latitude,longitude and north,east are max lat,lon you can get them from nominatim endpoint like this https://nominatim.openstreetmap.org/search?q=$country&format=json and key:boundingbox also this web app to get boundingbox : https://boundingbox.klokantech.com/ this is gist contain json with all boundingbox of countries: https://gist.github.com/graydon/11198540#gistcomment-2824611

liodali avatar Jul 27 '21 08:07 liodali

bad news is that this feature will available only for android/web because ios sdk have some limitation i will try to implemented by my own but it will in the future

liodali avatar Jul 27 '21 08:07 liodali