How to get the location of centered place pin on Map like uber android app

走远了吗. 提交于 2019-12-04 12:27:39

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:

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!