Location based on center of map


#1

We need to be able to read location based on center of the map. Most ride sharing apps use this feature so all users are accustomed doing that way when selecting a location.


#2

@rkresnadi, Can you please explain a bit more what you mean by this? I’m not quite understanding.


#3

I think what he means is ability to auto-center and auto-zoom a google map which has multiple markers (say two).
For example think of when you’re using the Google Maps app on your phone.
When you enter your start and end location, google maps shows the route from the start to end and automatically center and zoom the map so that the two points are visible on the map.

Currently in Dropsource the developer is expected to enter values for the Zoom Level and Center in the Set Visible Map Region action (See below).
If you’re dealing with a single marker then its easy to set these. You can simply set the Center to the single marker location.
But in the case where you have multiple markers, which is lot of cases, its extremely hard and nearly impossible (especially without calculation support) to know what values to set making this action not useful.

So basically what i think @rkresnadi is asking for is an option say a checkbox that developers can check and dropsource automatically calculates zoom level and center of the map based on the markers on a the given map view.

This is very doable in the google maps javascript SDK and i’ve done it before.
I don’t know about the google maps android/ios sdk but i expect it to to be doable too.


#4

@seanhoots I was going to ask about the one you described, thank you for elaborating. However, this post is for a different reason.

@wade, what I was thinking on this post is to be able to get the lat long based on the center of the map without the user click and hold the map. This is how uber works when you want to set the pick up location, all you need is drag the map and set your location on the center of the map. All ride sharing app do this.

@seanhoots, I don’t know if you knew this, bubble also has this feature where you can get the exact address of center of the map.

Hope this clears


#5

Yes i’m aware of it and I thought it was one of the things you were looking for.

Oh ok i get you. You basically want the center latlng of the map.
I think that should even be easier for dropsource to add. At least in code its just a one line.
You can get the target of the map camera, which always points to the center
LatLng mapcenter= map.getCameraPosition().target;

Alternatively they could get the bounds of the visible region of the map and get the center of the bounded box.
LatLng mapcenter = map.getProjection().getVisibleRegion().latLngBounds.getCenter();

I haven’t tried this before but i think they could use the similar method as the second one to get the center of the the map when given two or more markers.
They could create a builder from the markers, get the bounds of the builder and get the center.

I think all these are very doable if dropsource wants to implement them.


#6

These are great points made and I love the sharing of info @seanhoots and @rkresnadi… I’m going to write this up in our feature requests and point to this conversation for context. Perhaps this is data we can expose within the Map Kit functionalities.