1 | //Declaring some variables we will be using
|
---|
2 | var map;
|
---|
3 | var toggleState = 1;
|
---|
4 | var marker_hash = {};
|
---|
5 |
|
---|
6 | //This function is called from index.php
|
---|
7 | function initialize_map() {
|
---|
8 | //We will only do this function if the browser is compatible
|
---|
9 | if (GBrowserIsCompatible()) {
|
---|
10 | //Adding the google map into the div called #mapcanvas
|
---|
11 | map = new GMap2(document.getElementById("mapcanvas"));
|
---|
12 | //Center the map on Leiden
|
---|
13 | map.setCenter(new GLatLng(52.162687, 4.493294), 11);
|
---|
14 | map.setUIToDefault();
|
---|
15 |
|
---|
16 | //Go through the array 'markers' (Declared in index.php) and add a marker for each marker stored in the array using our addMarker function
|
---|
17 | for (var i=0; i<markers.length; i++) {
|
---|
18 | var current = markers[i];
|
---|
19 | var marker = addMarker(current);
|
---|
20 | marker_hash[current.id] = {marker : marker};
|
---|
21 | }
|
---|
22 | }
|
---|
23 | }
|
---|
24 |
|
---|
25 | //This function will contain the displaying and not displaying of nodes on the map
|
---|
26 | function toggleNodes() {
|
---|
27 | if (toggleState == 1) {
|
---|
28 | map.removeOverlay(geoXml);
|
---|
29 | toggleState = 0;
|
---|
30 | } else {
|
---|
31 | map.addOverlay(geoXml);
|
---|
32 | toggleState = 1;
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | //This function adds a marker with an object from our 'marker'array defined in index.php
|
---|
37 | function addMarker(current) {
|
---|
38 | var marker = new GMarker(new GLatLng(current.latitude[0], current.longitude[0]));
|
---|
39 | map.addOverlay(marker);
|
---|
40 | //Added mouseover listener that calls on our mouseOver function when the mouse moves over a marker on the map
|
---|
41 | GEvent.addListener(marker, 'mouseover', function() {
|
---|
42 | mouseOver(current.id, current.name[0]);
|
---|
43 | });
|
---|
44 | return marker;
|
---|
45 | }
|
---|
46 |
|
---|
47 | //Our mouseover function
|
---|
48 | function mouseOver(id, name)
|
---|
49 | {
|
---|
50 | //For now we only post the id(We made ourself in kmlHandler) and the name of the node
|
---|
51 | this.obj = document.getElementById("infotop");
|
---|
52 | obj.innerHTML = id+" - "+name;
|
---|
53 | //We will replace this function with a httprequest to a php file in the future
|
---|
54 | }
|
---|
55 |
|
---|