Someone please explain me how to get the location of centered place pin on Google Map Like in this Uber App. User can move the map but pin is always centered align and We can get the location as we keep moving the map.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use CurrentCenterPositionMap
First import the lib:
compile 'br.com.simplepass:mapfragmentwrapper:0.8.0'
Then, all you have to do is to put the MapFragmentWrapper xml tag as a container of your map fragment. Like this:
<br.com.simplepass.mapfragmentwrapper.MapFragmentWrapper
android:id="@+id/map_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/main_fragment_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</br.com.simplepass.mapfragmentwrapper.MapFragmentWrapper>
See the result:
回答2:
I'm not sure what language your using so here's a javascript solution. try creating latlng variable and using that variable to both place the marker and define center. You could do Something like this
var markerLatlng = new google.maps.LatLng ("your coords here");
var mapOptions = {
zoom :5,
center: markerLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var marker = new google.maps.Marker({
position: markerLatlng,
map: map,
animation: google.maps.Animation.DROP,
title: "your title here",
});
Hope this helps.