如何画线在地图上查看指定的坐标? [英] How to draw line on Map View given coordinates?

查看:134
本文介绍了如何画线在地图上查看指定的坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何绘制行图形页面指定的坐标?

How to draw line on MapView given coordinates?

AFAIK,在iPhone上是可能的。

AFAIK, on iPhone it is possible.

请指教。

在此先感谢。

推荐答案

要使用<一个href="http://$c$c.google.com/android/add-ons/google-apis/reference/index.html?com/google/android/maps/MapView.html">MapView您活动必须扩展<一href="http://$c$c.google.com/android/add-ons/google-apis/reference/index.html?com/google/android/maps/MapActivity.html">MapActivity.

有关你想画的每一行(或真的东西),你需要继承<一个href="http://$c$c.google.com/android/add-ons/google-apis/reference/index.html?com/google/android/maps/Overlay.html">Overlay并做了重叠的OnDraw()法绘图。一旦你创建了重叠将其添加到图形页面的东西,如 mMapView.getOverlays ()。新增(新MyOverlay());

For each line you want to draw (or really anything else) you need to subclass Overlay and do the drawing in the Overlay's onDraw() method. Once you've created your Overlay add it to the MapView with something like mMapView.getOverlays().add(new MyOverlay());.

在自定义的重叠你想获得一个<一个href="http://$c$c.google.com/android/add-ons/google-apis/reference/index.html?com/google/android/maps/Projection.html">Projection喜欢的东西投影P = MapView.getProjection()在; 。从投影您可以将GPS坐标与屏幕坐标投影的<一个href="http://$c$c.google.com/android/add-ons/google-apis/reference/com/google/android/maps/Projection.html#toPixels%28com.google.android.maps.GeoPoint,%20android.graphics.Point%29">toPixels(GeoPoint,点)方法,然后就画到在画布通过使用普通的Andr​​oid 2D绘制方法。

Inside your custom Overlay you'll want to get a Projection with something like Projection p = mapView.getProjection();. From the Projection you can convert GPS coordinates into screen coordinates with Projection's toPixels(GeoPoint, Point) method and then just draw to the passed in Canvas using normal Android 2D drawing methods.

这就是基础知识......如果你还需要什么,就问。

That's the basics... if you need anything else, just ask.

这篇关于如何画线在地图上查看指定的坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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