开发者

Get user location on map?

开发者 https://www.devze.com 2023-02-22 12:28 出处:网络
I have a map view that zooms and places markers. I to get the users location on start up. How would I go about do开发者_如何转开发ing this?

I have a map view that zooms and places markers. I to get the users location on start up. How would I go about do开发者_如何转开发ing this? Thanks in advance.


By on startup - I assume its application start up. Just register a LocationListener before you have your map view displayed. The callback to the LocationListener should give you the current co-ordinates. You can now use these co-ordinates to place markers.


   GeoPoint geoPoint = new GeoPoint((int) (your_location_variable.getLatitude() * 1E6),(int) (your_location_variable.getLongitude() * 1E6));
    mapController.animateTo(geoPoint);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号