CAN"覆盖"尺寸与Android上的谷歌地图一起缩放? [英] Can "overlay" size be zoomed together with the google map on android?

查看:168
本文介绍了CAN"覆盖"尺寸与Android上的谷歌地图一起缩放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够使用MapActivity和ItemizedOverlay绘制覆盖在谷歌地图Android上使用Eclipse。但是,当图被放大和缩小,覆盖层不改变大小。

I have been able to use "MapActivity" and "ItemizedOverlay" to draw overlays on google maps on android with Eclipse. But when the map is zooming in and out, the overlay does not change size.

我想覆盖要在地图上的固定的,并放大和缩小以及与地图。如何才能做到这一点?

I want the overlay to be "fixed" on the map, and zoom in and out along with the map. How can this be done?

我找不到教程来定义的边界(例如使用GPS坐标的角落的叠加图像)。请提供链接,如果你知道一些。

I can't find the tutorial to define a boundary (e.g. with GPS coordinates as corners for the overlay image). Please provide links if you know some.

和做任何其他方式?

非常感谢。

推荐答案

是的,有。我和我的应用程序有同样的问题。下面是一个例子,它完美的作品。这里所画的圆鳞,你在地图的放大和缩小。

Yes, there is. I had the same issue with my application. Here's an example and it works perfectly. The circle drawn here scales as you zoom in and out of the map.

在您的覆盖类:

public class ImpactOverlay extends Overlay {

private static int CIRCLERADIUS = 0;
private GeoPoint geopoint;

public ImpactOverlay(GeoPoint point, int myRadius) {
    geopoint = point;
    CIRCLERADIUS = myRadius;
}

@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    // Transfrom geoposition to Point on canvas
    Projection projection = mapView.getProjection();
    Point point = new Point();
    projection.toPixels(geopoint, point);

    // the circle to mark the spot
    Paint circle = new Paint();
    circle.setColor(Color.BLACK);
    int myCircleRadius = metersToRadius(CIRCLERADIUS, mapView, (double)geopoint.getLatitudeE6()/1000000);
    canvas.drawCircle(point.x, point.y, myCircleRadius, circle);
}

public static int metersToRadius(float meters, MapView map, double latitude) {
    return (int) (map.getProjection().metersToEquatorPixels(meters) * (1/ Math.cos(Math.toRadians(latitude))));         
}
}

随着覆盖从变焦重新绘制,标记将与它的基础上metersToRadius规模的调整。希望它能帮助。

As your overlay re-draws from zoom, the marker will resize with it based on the metersToRadius scale. Hope it helps.

这篇关于CAN"覆盖"尺寸与Android上的谷歌地图一起缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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