-1
Я попытался преобразовать этот образ SVG Stockholm City border SVG (граница города Стокгольма) в Google map Polygon.SVG to Google Map Polygon
Но окончательный полигон не в порядке. Существует код:
var width = 735, // width of SVG
height = 682; // height of SVG
function toLongitude(x) {
return x/height + 18.0780778;
}
function toLatitude(y) {
return y/width + 59.3325755;
}
function onLoad() {
// The SVG path;
var path = "M735.4,682.4 l0-1.2-0.2-2,0-2.5l1.5-2.9,0.3-6,1.3-9l0.9-2.8,0.1-5.8,0.7-8.8 l0.6-3.3,0.3-6.8,0.9-10.2l0.4-2.4-0.5-4.9,0.8-7.2l-0.6-3.1,0.7-5.7,2.7-8.1l0.4-0.5,0.6-1.2,0.9-1.9l-2.8,0.2-5.2,0.2-7.7,0.6 l-4.1,0.7-8.2,1.4-12.2,2.5l-0.8,0.2-2.1,0.4-2.7,0l-1-0.7-2.2,0-2.8-0.4l-1.8-2.1-3.6-3.9-4.9-5.9l-0.8-1.2-2.3-2.1-2.3-3.9 l0-1.2-1.1-2.5-1.6-3.4l-2-0.9-3.9-1.8-5.8-2.7l1-3.2-2-6.3,0-9.5l-2.7-3.5-2-7.5-2.1-11.4l1.5-1.2,0.6-2.7,0.7-4.1 l0.1-1.4,0-2.9,0-4.1l-9-2.7-17.7-5.3-26.3-7.9l-0.3-0.1-0.5-0.5-0.8-0.7l-0.7-3.6,0.7-7.3-0.8-10.7l0.4-1,0.8-2,1.2-3 l-0.1-0.1-0.6-0.4-0.6-0.6l0.5-2.9,1.2-5.8,2.2-8.4l-1.8-2.5-3.5-4.8-5.2-7.1l-0.7-1-1.5-1.9-2.3-2.9l-0.9-1-2-1.9-2.5-3.1 l-0.5-1.3-1.8-1.5-2.7-2.3l-4.1-3.7-7.8-7.7-12.4-10.8l-2-1.4-3.6-3.3-5.5-5l-2.1-1.8-3.9-3.9-6.4-5.3l-1.4-0.8-2.7-2.3-3.4-3.7 l-1.6-3.3-2.5-6.9-3.8-10.4l-0.6-1.5-0.6-3.1-0.8-4.2l4.7-6,8.4-12.1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3-2.9-6.1l-0.6-0.7-0.9-1.9-0.7-2.7l0.5-2.2,1.5-4.4,2.1-6.6 l0.3-1,0.3-2,1.5-2.2l1.3,0.6,2.6,1.1,4,1.7l0.8-0.9,1.5-1.7,2-2.4l0.6,0.4,1,0.6,1.3,0.8l2.1-1.5,4-2.9,5.7-4.2 l2.4,1.3,4.5,2.3,6.5,3.5l3.4,1.9,7,3.6,10.3,5.6l3.1,1.9,6.5,3,9.9,4.4l3.3,1.3,6.9,2.1,10.3,3.4l3.3,1.3,6.9,2.2,10.3,3.4 l4.9,1.7,9.7,3.5,14.7,4.9l0.3,0.8,0.6,1.6,0.9,2.4l0.3,1.2,1.2,1.8,2.4,2.2l4.6,1.7,9.3,3.4,13.9,5.1 C731.8,681.6,733.4,681.9,735.4,682.4z";
var points = path.match(/(\d+)/g);
var mapOptions = {
zoom: 11,
center: new google.maps.LatLng(59.3325755, 18.0780778),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById("map"),
mapOptions);
// Map polygon coordinates
var polyCoordinates = [];
for (var i = 0; i < points.length; i += 2) {
var longitude = toLongitude(parseInt(points[i])),
latitude = toLatitude(parseInt(points[i + 1]));
console.log(latitude + ', ' + longitude);
polyCoordinates.push(new google.maps.LatLng(latitude, longitude));
}
var polygon = new google.maps.Polygon({
paths: polyCoordinates,
strokeColor: '#000000',
strokeOpacity: 1,
strokeWeight: 1,
fillColor: '#ffff99',
fillOpacity: 0.85
});
polygon.setMap(map);
}
#map{
\t height: 100 %;
}
html, body{
\t height: 100 %;
\t margin : 0;
\t padding : 0;
}
<body>
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?callback=onLoad" async defer></script>
</body>
От SVG изображения Я извлек путь от пути id="City_border"
, удалить абсолютные координаты с самого начала и в конце пути SVG и заменить «с» с «L» (кривая к линиям).
Но я сделал что-то не так.
Любая идея?
Тот же результат, если я с помощью «C» вместо «л» – sasa