如何获得在Android上的纬度和经度的地图? [英] How to get the Latitude and Longitude on Map in Android?
问题描述
我怎样才能得到一个特定的位置,我早就点击在Android的地图?
How can I get the Latitude and Longitude values of a particular location that I have long clicked on the map in Android?
推荐答案
对于长按,我建议你看看<一href="http://www.kind-kristiansen.no/2010/handling-long$p$psslongclick-in-mapactivity/">http://www.kind-kristiansen.no/2010/handling-long$p$psslongclick-in-mapactivity/.这将进入详细讨论如何监听Maps API中长按事件,因为有很少或没有内置的功能,我所知道的。
For the long click, I suggest you check out http://www.kind-kristiansen.no/2010/handling-longpresslongclick-in-mapactivity/. This will go into detail on how to listen for long click events within the Maps API since there is little or no built-in functionality that I know of.
对于纬度/经度code,后,你长按即可翻译像素坐标。
As for the lat/lng code, after you get the long click you can translate the pixels to coordinates.
public void recieveLongClick(MotionEvent ev)
{
Projection p = mapView.getProjection();
GeoPoint geoPoint = p.fromPixels((int) ev.getX(), (int) ev.getY());
// You can now pull lat/lng from geoPoint
}
这篇关于如何获得在Android上的纬度和经度的地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!