如何在所有缩放级别中以相同的半径在Google地图v3中创建圈子? [英] How to create circle in google map v3 with same radius in all zoom level?

查看:92
本文介绍了如何在所有缩放级别中以相同的半径在Google地图v3中创建圈子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在v2中,我使用GProjection和Overlay创建了一个圆圈,它的外观尺寸看起来相同缩放级别。



在v3中,谷歌给出了Circle类,它将在地图上创建圆形,但它将在不同的缩放级别中更改。



我想创建在所有缩放级别都具有相同尺寸的圆圈。



我想通过Google Map v3了解其他任何方式所有缩放级别都有相同大小的圆圈。



预先感谢。 要在屏幕上创建具有相同像素大小的圆圈(与地理坐标中的相同面积大小相比),传统上会使用具有圆形形状的自定义图标的标记。但现在,您可以更灵活地使用v3中相对较新的符号。

  var marker = new google.maps.Marker {
position:new google.maps.LatLng(-122.5,47.5),
icon:{
path:google.maps.SymbolPath.CIRCLE,
fillOpacity:0.5,
fillColor:'#ff0000',
strokeOpacity:1.0,
strokeColor:'#fff000',
strokeWeight:3.0,
比例:20 //像素
}
});

另外:您也可以使用这些符号制作很酷的动画: http://googlegeodevelopers.blogspot.com/2012/06/powerful-data-visualization-with。 HTML


I am working on map code migration from v2 to v3.

In v2 i have create circle with help of GProjection and Overlay and it will look same size in all zoom level.

In v3 google gives Circle class that will create circle in map but it will change in different zoom level.

I want to create circle that will have same size in all zoom level.

I want to know any other way in google map v3 by that i can create circle with same size for all zoom level.

Thanks in advance.

解决方案

To create circles that are the same pixel size on the screen (versus same area size in geographic coordinates), you would traditionally use a Marker with a custom Icon in the shape of a circle. But now you can be more flexible and use the relatively new Symbols in v3.

var marker = new google.maps.Marker({
  position: new google.maps.LatLng(-122.5,47.5),
  icon: {
    path: google.maps.SymbolPath.CIRCLE,
    fillOpacity: 0.5,
    fillColor: '#ff0000',
    strokeOpacity: 1.0,
    strokeColor: '#fff000',
    strokeWeight: 3.0, 
    scale: 20 //pixels
  }
});

Aside: You can make cool animations out of these symbols as well: http://googlegeodevelopers.blogspot.com/2012/06/powerful-data-visualization-with.html

这篇关于如何在所有缩放级别中以相同的半径在Google地图v3中创建圈子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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