не выходит у меня каменный цветок. Помогите это сделать в цикл:
<div id="map"></div> +++ <div id="map2"></div>
<script>
var locations = [['Тула'],['Минск']];
var locations2 = [['Новосибирск'],['Бургас']];
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: {lat: 0,lng: 0},
disableDefaultUI: true,
scrollwheel: false
});
var markers = [];
var bounds = new google.maps.LatLngBounds();
geocoder = new google.maps.Geocoder();
for (var i = 0; i < locations.length; i++) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': locations[i][0]}, function(results, status) {
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
markers.push(marker);
bounds.extend(marker.getPosition());
map.fitBounds(bounds);
if (i > 0) {
var sitepath = new google.maps.Polyline({
path: [markers[0].getPosition(), marker.getPosition()],
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2,
map: map
});
}
});
}
var map2 = new google.maps.Map(document.getElementById('map2'), {
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: {lat: 0,lng: 0},
disableDefaultUI: true,
scrollwheel: false
});
var markers2 = [];
var bounds2 = new google.maps.LatLngBounds();
geocoder2 = new google.maps.Geocoder();
for (var i = 0; i < locations2.length; i++) {
var geocoder2 = new google.maps.Geocoder();
geocoder.geocode({'address': locations2[i][0]}, function(results, status) {
var marker2 = new google.maps.Marker({
map: map2,
position: results[0].geometry.location
});
markers2.push(marker2);
bounds2.extend(marker2.getPosition());
map2.fitBounds(bounds2);
if (i > 0) {
var sitepath = new google.maps.Polyline({
path: [markers2[0].getPosition(), marker2.getPosition()],
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2,
map: map2
});
}
});
}
}
</script>