gmaps.js
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var geocoder;
var map;
var addresses = new Array("óë Ãëóáî÷èöêàÿ, 53, Êèåâ","ïð.×åðíîâîëà, 45á Ëüâîâ","óë. Íàáåðåæíàÿ Ïîáåäû, 118, Äíåïðîïåòðîâñê","ïð. Ëåíèíà, 45/2. Cò.ìåòðî 23 àâãóñòà, Õàðüêîâ","óë. Êðàñíîâà,12, Îäåññà");
var names = new Array("Êèåâ, óë Ãëóáî÷èöêàÿ, 53","Ëüâîâ, óë.Ñòðûéñêàÿ, 30","Äíåïðîïåòðîâñê, óë. Íàáåðåæíàÿ Ïîáåäû, 118","Õàðüêîâ, ïð. Ëåíèíà, 45/2. Cò.ìåòðî 23 àâãóñòà","Îäåññà, óë. Êðàñíîâà,12");
var counter=0;
function load()
{
// Create new map object
map = new GMap2(document.getElementById("map"));
// Create new geocoding object
geocoder = new GClientGeocoder();
// Retrieve location information, pass it to addToMap()
for (i=0; i < addresses.length; i++)
geocoder.getLocations(addresses[i], addToMap);
}
function createMarker(point,html)
{
var marker = new GMarker(point);
GEvent.addListener(marker, "mouseover", function() {marker.openInfoWindowHtml(html);});
return marker;
}
// This function adds the point to the map
function addToMap(response)
{
// Retrieve the object
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
htmlText="<b>"+names[counter]+"</b>";
// Create a marker
marker=createMarker(point, htmlText);
map.addOverlay(marker);
marker.openInfoWindowHtml(htmlText);
if (counter==0)
{
map.setCenter(point, 5);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
}
counter++;
}