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