[7722] | 1 | //Declaring some variables we will be using
|
---|
[7694] | 2 | var map;
|
---|
| 3 | var toggleState = 1;
|
---|
[7722] | 4 | var marker_hash = {};
|
---|
[7665] | 5 |
|
---|
[7722] | 6 | //This function is called from index.php
|
---|
[7694] | 7 | function initialize_map() {
|
---|
[7722] | 8 | //We will only do this function if the browser is compatible
|
---|
[7694] | 9 | if (GBrowserIsCompatible()) {
|
---|
[7722] | 10 | //Adding the google map into the div called #mapcanvas
|
---|
[7694] | 11 | map = new GMap2(document.getElementById("mapcanvas"));
|
---|
[7722] | 12 | //Center the map on Leiden
|
---|
[7694] | 13 | map.setCenter(new GLatLng(52.162687, 4.493294), 11);
|
---|
| 14 | map.setUIToDefault();
|
---|
[7722] | 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 | }
|
---|
[7694] | 22 | }
|
---|
| 23 | }
|
---|
| 24 |
|
---|
[7722] | 25 | //This function will contain the displaying and not displaying of nodes on the map
|
---|
| 26 | function toggleNodes() {
|
---|
[7694] | 27 | if (toggleState == 1) {
|
---|
| 28 | map.removeOverlay(geoXml);
|
---|
| 29 | toggleState = 0;
|
---|
| 30 | } else {
|
---|
| 31 | map.addOverlay(geoXml);
|
---|
| 32 | toggleState = 1;
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
[7722] | 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 | }
|
---|
[7665] | 55 |
|
---|