以米为单位设置线宽的谷歌折线 [英] Draw google polyline with line width set in meters

查看:104
本文介绍了以米为单位设置线宽的谷歌折线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当您在Google地图中绘制多段线时,您将它设置为像素宽度(strokewidth)。有没有办法以米为单位设置?

解决方案

不幸的是,我不知道任何简单的方法来做到这一点。这个API似乎没有关于这方面的文档,我认为这个功能是不支持的。



一个问题是像素代表不同数量的米在不同的缩放级别API。因此,如果缩放级别发生变化,它将是一个动态数量。



一个选项可能是计算给定缩放比例的给定数量的像素宽度水平。为此,您必须根据每个缩放级别的地图比例编写自己的功能。这些数据似乎可以在这里找到:



http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#designing_overlay_gm_mve.htm

  20:1128.497220 
19:2256.994440
18:4513.988880
17:9027.977761
16:18055.955520
15:36111.911040
14:72223.822090
13:144447.644200
12:288895.288400
11:577790.576700
10:1155581.153000
9:2311162.307000
8:4622324.614000
7:9244649.227000
6:18489298.450000
5:36978596.910000
4:73957193.820000
3:147914387.600000
2:295828775.300000
1:591657550.500000

然后,您可以根据您要表示的米和当前缩放级别动态设置像素值。



可能仍有问题,因为像素大小生成,可能与屏幕像素尺寸不一致,具体取决于API处理屏幕DPI和分辨率的方式

I noticed that when you draw a polyline in google maps you set it's width in pixels (strokewidth). Is there a way I could set that in metres instead?

解决方案

Unfortunately, I don't know any easy way to do this. The API does not appear to have documentation on this and I assume this feature is unsupported.

One problem is that the pixels represent a different number of meters at different zoom levels within the API. So it would be a dynamic quantity if the zoom levels are changed.

One option might be to compute the width in pixels for representing a given number of meters for a given zoom level. For that, you would have to write your own function based on the scales of the map at each zoom level. That data appear to be available here:

http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#designing_overlay_gm_mve.htm

20 : 1128.497220
19 : 2256.994440
18 : 4513.988880
17 : 9027.977761
16 : 18055.955520
15 : 36111.911040
14 : 72223.822090
13 : 144447.644200
12 : 288895.288400
11 : 577790.576700
10 : 1155581.153000
9  : 2311162.307000
8  : 4622324.614000
7  : 9244649.227000
6  : 18489298.450000
5  : 36978596.910000
4  : 73957193.820000
3  : 147914387.600000
2  : 295828775.300000
1  : 591657550.500000

you can then set the pixel value dynamically depending on the meters you are trying to represent and the current zoom level.

There may still be a problem because the pixel sizes you generate, may not correspond to the screen pixel sizes, depending on how the API deals with screen DPI and resolution

这篇关于以米为单位设置线宽的谷歌折线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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