如何获得在Android上的纬度和经度的地图? [英] How to get the Latitude and Longitude on Map in Android?

查看:117
本文介绍了如何获得在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆