如何画线在地图上查看指定的坐标?在地、坐标、图上、画线

由网友(青衫烟雨)分享简介:如何绘制行图形页面指定的坐标?How to draw line on MapView given coordinates?AFAIK,在iPhone上是可能的。AFAIK, on iPhone it is possible.请指教。 在此先感谢。推荐答案要使用MapView您活动必须扩展MapActivit...

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

How to draw line on MapView given coordinates?

AFAIK,在iPhone上是可能的。

AFAIK, on iPhone it is possible.

请指教。

在此先感谢。

推荐答案

要使用MapView您活动必须扩展MapActivity.

有关你想画的每一行(或真的东西),你需要继承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());.

在自定义的重叠你想获得一个Projection喜欢的东西投影P = MapView.getProjection()在; 。从投影您可以将GPS坐标与屏幕坐标投影的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.

阅读全文

相关推荐

最新文章