静态地图API讨论路径,但没有提及圆圈。这可能吗? 谢谢是否可以在Google静态地图上绘制圆圈?
回答
你可以做的是使用encoded polyline algorithm产生足够的点来获得一个大致的圆形路径。确实存在编码问题:您需要获取圆的中心和半径,将其转化为一系列经纬度,然后使用该算法进行编码。
作为替代方案,您可能能够使用一个透明的gif图片作为标记,并把在你的地图。
这是可能的,但你必须绘制形状有很多面的,看起来像一个圆圈。
这是我的例子:
<img src="http://maps.google.com/maps/api/staticmap?size=600x500&path=fillcolor:0x0000FF|weight:3|color:0xFF0000|enc:ue{cI|rrH`@[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@`[email protected]@dWy`@nX{]vY{ZxZuWx[kTr\_Qh]oMz]}If^iFl^uBn^?n^tBd^hFz]|Ih]nMr\~Px[jTxZtWvYzZnXz]dWx`@[email protected]`T`[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected]`[email protected]@[email protected]@[email protected]@[email protected]@eWx`@oX|]wYzZyZtWy[jTs\~Pi]lM{]|Ie^jFo^rBo^?m^sBg^kF{]}Ii]mMs\_Qy[kTyZuWwY{ZoX}]eWy`@[email protected]@[email protected]@[email protected]{[email protected]@[email protected][email protected]@[email protected]@[email protected]&sensor=true" border="0"/>
为了产生这个我以前freemaptools.com
任何方式来使这种动态?如果我有许多不同的坐标使用? – 2015-03-23 13:51:16
@JonasB这是可能的。寻找折线生成器。如果这有什么用处,我已经为此做了一个角度指示? – sidonaldson 2015-03-27 20:28:56
这是值得注意的,网站使用PHP折线编码器(来自客户端的源代码:'xmlHttp.open( “POST”, “AJAX/CSV-折线-encoder.php”,TRUE);')。 – 2016-02-25 15:22:45
您可以通过绘图详细PolyLine
表示绕圈,因为谷歌静态地图不支持自己画一个圆圈。
Here is a request example包含2圈半径0.5和5公里。请记住,您需要一个算法才能生成正确的编码多段线。我使用这个implementation,因为我是用PHP编写的,但是你可以根据你想要的语言自己找到或开发类似的东西。
这里是我用来生成请求的PHP代码:
<?php
/* set some options */
$mapLat = filter_input(INPUT_POST, 'lat1'); // latitude for map's and circle's center
$mapLng = filter_input(INPUT_POST, 'lon1'); // longitude for map's and circle's center
$mapRadius1 = 0.5; // the radius of the first circle (in Kilometres)
$mapRadius2 = 5; // the radius of the second circle (in Kilometres)
$mapFill_first = '330000'; // fill colour of the first circle
$mapFill_second = 'FF99FF'; // fill colour of the second circle
$map1Border1 = '91A93A'; // border colour of the first circle
$map1Border2 = '0000CC'; // border colour of the second circle
$mapWidth = 450; // map image width (max 640px)
$mapHeight = 450; // map image height (max 640px)
$zoom = 11;
$scale = 2;
/** create our encoded polyline string for the first circle*/
$EncString1 = GMapCircle($mapLat, $mapLng, $mapRadius1);
/** create our encoded polyline string for the second circle*/
$EncString2 = GMapCircle($mapLat, $mapLng, $mapRadius2);
/** put together the static map URL */
$MapAPI = 'http://maps.google.com.au/maps/api/staticmap?';
$MapURL = $MapAPI . 'center=' . $mapLat . ',' . $mapLng . '&zoom=' . $zoom . '&size=' .
$mapWidth . 'x' . $mapHeight . '&scale=' . $scale . '&markers=color:red%7Clabel:S%7C'.$mapLat.','.$mapLng .
'&maptype=roadmap&path=fillcolor:0x' . $mapFill_first .
'33%7Ccolor:0x' . $map1Border1 . '00%7Cenc:' . $EncString1 . '&path=fillcolor:0x' .
$mapFill_second . '33%7Ccolor:0x' . $map1Border2 . '00%7Cenc:' . $EncString2;
/* output an image tag with our map as the source */
//echo '<img src="' . $MapURL . '" />';
echo json_encode($MapURL);
function GMapCircle($Lat, $Lng, $Rad, $Detail = 8)
{
$R = 6371;
$pi = pi();
$Lat = ($Lat * $pi)/180;
$Lng = ($Lng * $pi)/180;
$d = $Rad/$R;
$points = array();
for ($i = 0; $i <= 360; $i += $Detail)
{
$brng = $i * $pi/180;
$pLat = asin(sin($Lat) * cos($d) + cos($Lat) * sin($d) * cos($brng));
$pLng = (($Lng + atan2(sin($brng) * sin($d) * cos($Lat), cos($d) - sin($Lat) * sin($pLat))) * 180)/$pi;
$pLat = ($pLat * 180)/$pi;
$points[] = array($pLat, $pLng);
}
require_once('PolylineEncoder.php');
$PolyEnc = new PolylineEncoder($points);
$EncString = $PolyEnc->dpEncode();
return $EncString['Points'];
}
由于jomacinc的教程,享受:)
您可以通过使用computeOffset方法很容易接近的圆这可以让你沿着圆周找到坐标。
在这个例子中我使用的8度的增量,所以这会给45双坐标。对于圆圈大小,我使用的是在静态地图中很好地显示的圆圈。如果您使用大圆圈,则只需将增量更改为更小的值,例如j = j + 6。
将变量pathText
添加到静态地图所需的其余网页地址。
var pathText = '&path=';
var circumLatLng;
for (var j = 0; j < 361; j = j + 8) {
circumLatLng = google.maps.geometry.spherical.computeOffset(circle.getCenter(), circle.getRadius(), j);
pathText += circumLatLng.lat().toFixed(6) + ',' + circumLatLng.lng().toFixed(6) + '|';
}
- 1. 绘制圆圈Google静态地图
- 2. 是否可以在Google地图上绘制一个圆圈并检查坐标落在圆上?
- 3. 如何在Google地图上绘制静态目标圈?
- 4. 动态地图在地图上绘制圆圈
- 5. Google Maps v3 API - 在地图上绘制圆圈
- 6. 在Google地图V2 API上绘制多个圆圈
- 7. 使用AJAX通过Google地图动态绘制圆圈
- 8. 如何在UISlider上绘制静态圆圈?
- 9. 无法在位图上绘制圆圈?
- 10. 如何在圆圈上绘制图像
- 11. 无法在Google地图中绘制圆圈?
- 12. Google地图是否可以在地图上绘制多个多边形?
- 13. 谷歌地图Api绘制圆圈
- 14. 如何在Google地图中绘制圆圈之前离开模式绘图
- 15. 在用户滚动时在地图上绘制圆圈
- 16. 通过传递参数到URL在Google地图上绘制圆圈
- 17. 如何在Google Maps API上的圆圈内绘制圆圈并进行搜索?
- 18. 在谷歌地图上绘制多个重叠的圆圈
- 19. 使用JavaScript在谷歌地图上绘制虚线圆圈
- 20. 绘制圆圈vhdl
- 21. 在Winform外绘制圆圈
- 22. 在C++中绘制圆圈
- 23. 在android中绘制圆圈
- 24. 在MATLAB中绘制圆圈
- 25. iOS在导航栏上绘制圆圈
- 26. 在画布上绘制交互圆圈
- 27. 在地图上绘制圆图Matlab
- 28. 无法使用谷歌地图api在谷歌地图上绘制圆圈
- 29. 如何在地图上制作动态圆圈?
- 30. Google地图检查地图边界是否存在圆圈边界
注意,标记有大小限制。 100px乘100px对我不起作用,但75px乘75px。 – kingjeffrey 2011-04-15 18:56:21
的问题是,这取决于你最终可能会需要一分不少,使其真正看起来像一个圆圈,因此,你可能无法达到URL字符圆的长度(有1024个字符的限制目前) – renatoargh 2017-05-11 23:16:00
2048个字符,对不起 – renatoargh 2017-05-12 13:47:35