如何渲染图形页面为圆? [英] How to render mapview as a circle?

查看:132
本文介绍了如何渲染图形页面为圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不要与图纸上的图形页面的圆相混淆。我试图做到以下几点。

Not to be confused with drawing a circle ON mapview. I'm trying to accomplish the following.

我应该,以及如何:
一)创建的MapView作为另一个View圆形的看法?
b)将的MapView全屏和覆盖另一种观点以透明圈?

Should I, and how: a) create the MapView as a circular view on another View? b) render the MapView fullscreen and overlay another view with a transparent circle?

我不知道如果这些选项都是可能的,我认为他们是。如果有帮助,因为部分用户的工作流程不透明区域将有几个按钮,但最终会消失,用户将剩下的全屏幕地图进行交互。

I'm not sure if either of these options are possible, I assume they are. If it helps, as part of the user workflow the opaque area will have a couple of buttons but will eventually go away and the user will be left with the full screen map to interact with.

感谢

推荐答案

试试这个code

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mapView = (MapView) findViewById(R.id.mapview);
    MapController mc = mapView.getController();
    MyLocationOverlay myLocationOverlay = new MyLocationOverlay(MainMap.this, mapView);
    mapView.getOverlays().add(myLocationOverlay);
    mc.animateTo( new GeoPoint(lat, lng));
    mc.setZoom(15);
    mapView.invalidate();
}

不要忘了添加overlay.enableMyLocation();在onresume()和overlay.disableMyLocation();在暂停

Dont forget to add overlay.enableMyLocation(); in onresume() and overlay.disableMyLocation(); in on pause

代替上面的code的:

Instead of the above code if you want to draw circle around you point you can use following sample code:

Point screenPnts =new Point();
GeoPoint curr_geopoint = new GeoPoint((int)(location.getLatitude()*1E6),(int)(location.getLongitude()*1E6));
mapview.getProjection().toPixels(curr_geopoint, screenPnts);
canvas.drawCircle(screenPnts.x, screenPnts.y, 15, paint);

这篇关于如何渲染图形页面为圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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