DDanser,
Попробуйте покликать по Рим Москва под картой
<!DOCTYPE html>
<html>
<head>
<title>Sample Map</title>
<meta charset="utf-8">
<script src="http://maps.google.com/maps/api/js"> </script>
<script>
var map;
var places = [{ city: "Рим", LatLng: { lat: 41.881576, lng: 12.495232} },
{ city: "Москва", LatLng: { lat: 55.755833, lng: 37.617778}}];
function e() {
var centerLatLng = { lat: 41.881576, lng: 12.495232 };
var e = document.getElementById("map"),
t = {
center: centerLatLng,
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(e, t);
};
google.maps.event.addDomListener(window, 'load', e);
function setmarker(elem) {
var cityname = elem.innerText;
for (var i = 0; i < places.length; i++) {
if (places[i].city == cityname) {
marker = new google.maps.Marker({
position: places[i].LatLng,
map: map,
title: places[i].city
});
marker.setMap(map);
map.setCenter(places[i].LatLng);
}
}
}
</script>
</head>
<body>
<div id="map" style="width: 800px; height: 400px;">
</div>
<div onclick="setmarker(this)">Рим</div>
<div onclick="setmarker(this)">Москва</div>
</body>
</html>