靜態地圖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