ОК, поэтому у меня есть многоугольник, который представлен как закодированная полилиния. Я хотел бы поместить это на карту, но не могу понять синтаксис. Вот что я получил:
setRegion = new google.maps.Polyline({
locations: "}[email protected]\[email protected]@r{[email protected]@[email protected]@[email protected]}[email protected]_h|@r{Zad\y|_D}[email protected]@[email protected]}llBpoZqa{@[email protected]~eBaaX}{[email protected]}[email protected]`dYs_NquNgbjAf{[email protected]|[email protected]@}[email protected]}[email protected]|[email protected]@r{ZhjFr}[email protected]}@[email protected]@",
levels: "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35
});
setRegion.setMap(map);
Что я создал с помощью Инструмент Polyline Encoder. С этой же страницы я получил ее использование, которое:
Количественная полилиния будет отображаться в закодированная полилиния и кодировка Поля уровней ниже. Используйте эти значения для местоположений и уровней, когда вы создайте свою google.maps.Polyline
Однако многоугольник не появляется. Кто-нибудь знает, что происходит не так?
ОБНОВЛЕНИЕ
Я пробовал это, но получаю сообщение об ошибке Uncaught TypeError: Cannot read property 'encoding' of undefined
.
<!doctype html>
<html>
<head>
<title>Test</title>
<meta charset="iso-8859-1">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false"></script>
<style type="text/css">
#map {width:670px;height:600px;}
</style>
<script type='text/javascript'>
function initialize() {
var myLatlng = new google.maps.LatLng(51.65905179951626, 7.3835928124999555);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var decodedPath = google.maps.geometry.encoding.decodePath("}[email protected]\[email protected]@r{[email protected]@[email protected]@[email protected]}[email protected]_h|@r{Zad\y|_D}[email protected]@[email protected]}llBpoZqa{@[email protected]~eBaaX}{[email protected]}[email protected]`dYs_NquNgbjAf{[email protected]|[email protected]@}[email protected]}[email protected]|[email protected]@r{ZhjFr}[email protected]}@[email protected]@");
var decodedLevels = decodeLevels("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB");
setRegion = new google.maps.Polyline({
locations: decodedPath,
levels: decodedLevels,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
setRegion.setMap(map);
}
function decodeLevels(encodedLevelsString) {
var decodedLevels = [];
for (var i = 0; i < encodedLevelsString.length; ++i) {
var level = encodedLevelsString.charCodeAt(i) - 63;
decodedLevels.push(level);
}
return decodedLevels;
}
</script>
</head>
<body onload="initialize()">
<div id="map"></div>
</body>
</html>