如何获取我在Android中长时间点击地图的特定位置的纬度和经度值?如何在Android上获取地图的纬度和经度?
13
A
回答
13
对于长时间点击,我建议你退房http://www.kind-kristiansen.no/2010/handling-longpresslongclick-in-mapactivity/。这将详细介绍如何侦听Maps API中的长时间点击事件,因为我知道的内置功能很少或没有。
至于lat/lng代码,获得长按后,您可以将像素转换为坐标。
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
}
4
你必须管理LongClick事件,然后使用代码,找出经度和纬度与下面的代码:
GeoPoint geoPoint=mapView.getProjection().fromPixels((int)event.getX(),(int)event.getY());
int latitude = geoPoint.getLatitudeE6();
int longitude = geoPoint.getLongitudeE6();
其中“事件”是“MotionEvent”的对象。
根据您的情况使用任何其他事件。
0
它提供经度和纬度上的地图点点击
map.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng point) {
//myMap.addMarker(new MarkerOptions().position(point).title(point.toString()));
//The code below demonstrate how to convert between LatLng and Location
//Convert LatLng to Location
Location location = new Location("Test");
location.setLatitude(point.latitude);
location.setLongitude(point.longitude);
location.setTime(new Date().getTime()); //Set time as current Date
txtinfo.setText(location.toString());
//Convert Location to LatLng
LatLng newLatLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions()
.position(newLatLng)
.title(newLatLng.toString());
map.addMarker(markerOptions);
}
});
相关问题
- 1. 如何从Android上的地址获取纬度和经度?
- 2. 如何从Android上的地址获取纬度和经度?
- 3. 如何获取谷歌地图上的纬度和经度
- 4. 如何在Android中获取纬度和经度或谷歌地图的高度?
- 5. 如何从Android的纬度和经度获取地址?
- 6. 如何从谷歌地图获取经度和纬度的place_id?
- 7. 如何获取谷歌地图中心的经度和纬度
- 8. 获取纬度和经度
- 9. 获取经度和纬度
- 10. Android:获取纬度和经度
- 11. 无法获取经度和纬度android
- 12. 如何从谷歌地图获取纬度和经度?
- 13. 如何在地图上显示地图的纬度和经度(Android Studio)
- 14. 如何获得地址的纬度和经度?谷歌地图
- 15. iphone谷歌地图获取地址的经度和纬度
- 16. 如何在墨卡托地图(JPEG)上从x,y获取纬度和经度?
- 17. 如何获取纬度和经度这里使用android SDK的地图?
- 18. 获取经纬度,Android
- 19. 地球纬度和经度在3D球体上的纬度和经度
- 20. 如何在Android中通过GPS获取经度和纬度?
- 21. 如何在离线模式下获取纬度和经度android
- 22. 如何在角度谷歌地图中获取center_changed纬度和经度
- 23. 如何从MKMapkit中的地址获取纬度和经度?
- 24. 如何从C#中的地址获取纬度和经度
- 25. 获取当前纬度和经度在android上
- 26. Ios地图:获取经纬度
- 27. 从谷歌地图获取经纬度
- 28. 如何获取Android中某个人的经度和纬度?
- 29. 如何获取经度和纬度的Android
- 30. 如何获取Android开发中的精确经度和纬度?
链接在这个答案指向一个博客帖子我写了一段时间回来。我刚刚写了一篇新文章,提供了一个更清洁,效果更好的解决方案。这可能是有趣的:http://www.kind-kristiansen.no/2011/android-handling-longpresslongclick-on-map-revisited/ – rogerkk 2011-04-19 10:30:32