]>
Commit | Line | Data |
---|---|---|
455492e8 ER |
1 | function setMapCookie(map) { |
2 | document.cookie = 'googlemaplng=' + map.getCenter().lng(); | |
3 | document.cookie = 'googlemaplat=' + map.getCenter().lat(); | |
4 | var zoom = map.getZoom(); | |
5 | document.cookie = 'googlemapzoom=' + zoom; | |
6 | document.layoutform.scaling_factor.value =+ zoom; | |
7 | } | |
8 | ||
9 | function readCookie(name) { | |
10 | var nameEQ = name + "="; | |
11 | var ca = document.cookie.split(';'); | |
12 | for(var i=0;i < ca.length;i++) { | |
13 | var c = ca[i]; | |
14 | while (c.charAt(0)==' ') c = c.substring(1,c.length); | |
15 | if (c.indexOf(nameEQ) == 0) { | |
16 | c=c.substring(nameEQ.length,c.length); | |
17 | while (c.substring(c.length-1, c.length) == ' ') | |
18 | c = c.substring(0,c.length-1); | |
19 | return c; | |
20 | } | |
21 | } | |
22 | return null; | |
23 | } | |
24 | ||
25 | function createMarker(hostname, comment, lat, long, state) { | |
26 | var point = new GLatLng(lat,long); | |
27 | var marker; | |
28 | if (state == "Up") { | |
29 | var baseIcon = new GIcon(); | |
30 | baseIcon.shadow = gstatusmap.images_url + "shadow50.png"; | |
31 | baseIcon.iconSize = new GSize(20, 34); | |
32 | baseIcon.shadowSize = new GSize(37, 34); | |
33 | baseIcon.iconAnchor = new GPoint(9, 34); | |
34 | baseIcon.infoWindowAnchor = new GPoint(9, 2); | |
35 | baseIcon.infoShadowAnchor = new GPoint(18, 25); | |
36 | var okicon = new GIcon(baseIcon); | |
37 | okicon.image = gstatusmap.images_url + "marker.png"; | |
38 | marker = new GMarker(point, okicon); | |
39 | } else { | |
40 | marker = new GMarker(point); | |
41 | } | |
42 | GEvent.addListener(marker, "click", function() { | |
43 | marker.openInfoWindowHtml("<b>" + hostname + "</b><br/>" + comment + "<br/>State: " + state + ""); | |
44 | }); | |
45 | return marker; | |
46 | } | |
47 | ||
48 | function load() { | |
49 | if (!GBrowserIsCompatible()) { | |
50 | return | |
51 | } | |
52 | ||
53 | var map = new GMap2(document.getElementById("map")); | |
54 | map.addControl(new GLargeMapControl3D()); | |
55 | map.addControl(new GOverviewMapControl()); | |
56 | map.addControl(new GMenuMapTypeControl()); | |
57 | ||
58 | GEvent.addListener(map, "click", function () { | |
59 | setMapCookie(map); | |
60 | }); | |
61 | GEvent.addListener(map, "move", function () { | |
62 | setMapCookie(map); | |
63 | }); | |
64 | GEvent.addListener(map, "zoom", function () { | |
65 | setMapCookie(map); | |
66 | }); | |
67 | var googlemaplat = readCookie('googlemaplat'); | |
68 | var googlemaplng = readCookie('googlemaplng'); | |
69 | var centerPoint; | |
70 | if (googlemaplng != null && googlemaplat != null) { | |
71 | centerPoint = new GLatLng(googlemaplat, googlemaplng); | |
72 | } else { | |
73 | centerPoint = new GLatLng(gstatusmap.lat, gstatusmap.lng); | |
74 | } | |
75 | ||
76 | var scale = readCookie('googlemapzoom') || gstatusmap.scale || 100; | |
77 | map.setCenter(centerPoint, parseInt(scale)); | |
78 | document.layoutform.scaling_factor.value = scale; | |
79 | ||
80 | // insert markers | |
81 | for (var i in gstatusmap.markers) { | |
82 | var marker = gstatusmap.markers[i]; | |
83 | if (marker) { | |
84 | map.addOverlay(createMarker(marker[0], marker[1], marker[2], marker[3], marker[4])); | |
85 | } | |
86 | } | |
87 | } |