//button outside the map!"); }); } updateMarker(); GEvent.addListener(map, 'moveend', function() { if (showtags) update_map(); updateMarker(); }); GEvent.addListener(map, 'move', function() { updateMarker(); }); if (justswitched) alert ("You have just switched to google.maps. Please check location on map"); } } //updates the center marker function updateMarker() { marker.setPoint(map.getCenter()); display_latlon.firstChild.nodeValue = "LAT = "+map.getCenter().lat()+" LON = "+map.getCenter().lng(); if (echocoords){ coord_lat.value = map.getCenter().lat(); coord_lon.value = map.getCenter().lng(); } } //returns a marker ressource function createMarker(point, id, name, description, login) { //ii = new GIcon(tagicon); /*if (icon.length > 0) { ii.image = ""+icon; }*/ var marker = new GMarker(point, tagicon); var html; html = "" + name + ""; if (description.length > 0) html += "
"+description; html += "
ID"+id; html += " by "+login; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; } //AJAXy thing that requests tags from server and draws them. function update_map() { if (running) { request.abort(); running = false; } if (shownall == false || map.getZoom() <= prevZoom) { var bounds = map.getBounds(); var southWest=bounds.getSouthWest(); var northEast=bounds.getNorthEast(); boxdim_height = mapbox.offsetHeight; boxdim_width = mapbox.offsetWidth; bounds_dist_lat = (northEast.lat() - southWest.lat()) * 3600 * 1000; bounds_dist_lon = (northEast.lng() - southWest.lng()) * 3600 * 1000; latperpixel = bounds_dist_lat / boxdim_height; lonperpixel = bounds_dist_lon / boxdim_width; request = GXmlHttp.create(); if (bounds.isFullLng()) var requestfile = "points.xml.php"; else var requestfile = "points.xml.php?sw_lat="+ southWest.lat() + "&sw_lon="+ southWest.lng() + "&ne_lat=" + northEast.lat() + "&ne_lon=" + northEast.lng() +"&latpp="+latperpixel+"&lonpp="+lonperpixel; request.open("GET", requestfile, true); if (d) d.innerHTML = requestfile; request.onreadystatechange = function() { if (request.readyState == 4 && running) { m.innerHTML = "Reading XML.."; var xmlDoc = request.responseXML; if (!xmlDoc.documentElement) { m.innerHTML = "Error: Unable to Parse XML"; running = false; return; } var markers = xmlDoc.documentElement.getElementsByTagName("marker"); m.innerHTML = "Drawing tags..."; for (var i = 0; i < markers.length; i++) { id = markers[i].getAttribute("tag_ID"); if (marks[id] && marks[id] != null) { //we have this one so lets flag it as valid marks[id].old = false; } else { var point = new GPoint( parseFloat(markers[i].getAttribute("lng")), parseFloat(markers[i].getAttribute("lat"))); marks[id] = createMarker(point,id,markers[i].getAttribute("name"),markers[i].getAttribute("description"),markers[i].getAttribute("login")); map.addOverlay(marks[id]); //map.overlays.push(marks[id]); marks[id].isnew = true; } if (!lists[id] || lists[id] == null) { lists[id] = new Object(); lists[id].name = markers[i].getAttribute("name"); lists[id].id = id; } } m.innerHTML = "Removing drawn tags..."; for (i in marks) if (marks[i] != null) { if (marks[i].old == true) { map.removeOverlay(marks[i]); marks[i] = null; lists[i] = null; //marks.splice(i,1); } else { if (marks[i].isnew == true) { //marks[i].initialize(map); //marks[i].redraw(true); marks[i].isnew = false; } //flag all current markers as old, will be reset if coming new marks[i].old = true; } } //print out a message var count = xmlDoc.documentElement.getElementsByTagName("countall"); if (count && count.length > 0) { c = count[0].getAttribute("value"); if (markers.length == c) { m.innerHTML = "Showing "+markers.length+" denCity.net tags"; shownall = true; } else { m.innerHTML = "Showing "+markers.length+" of "+c+" tags in this area, zoom-in for more"; shownall = false; } } else { m.innerHTML = "Showing "+markers.length+" of an unknown number of denCity.net tags"; shownall = true; } running = false; updateMarker(); if (listtags == true) gibdenlist(); //if tag is centered, open its info window. but only once (clear tag_ID afterwards) if (tag_ID && marks[tag_ID]) { GEvent.trigger(marks[tag_ID]); tag_ID = false; } } }//end function m.innerHTML = "Requesting DATA"; running = true; request.send(null); } prevZoom = map.getZoom(); } /* class listob { var name; var id; function listob() { } }*/ function showAddress(address) { var tagaddress = document.getElementById('tagaddress'); var tagedit_address = document.getElementById('tagedit_address'); if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, geocoder_zoom); marker.openInfoWindowHtml(address); tagedit_address.value = address; } } ); } } function gibdenlist() { var waswarda = m.innerHTML; m.innerHTML = "Listing tags..."; nimmdenlist(); for (i in lists){ if (lists[i] != null) denListe.innerHTML += ""+lists[i].name+"..."; } m.innerHTML = waswarda; } function nimmdenlist() { denListe.innerHTML = ""; } function cleardencitytags() { if (running) { request.abort(); } running = false; request = null; //map.clearOverlays(); for (i in marks) { map.removeOverlay(marks[i]); } marks = new Array(); } function refresh_map() { cleardencitytags(); update_map(); } function switchdentag() { if (showtags == true) { cleardencitytags(); showtags = false; m.innerHTML = "no tags are displayed (click on \"show tags\" to enable this feature)"; document.getElementById('toggledentag').innerHTML = "show tags"; } else { showtags = true; refresh_map(); document.getElementById('toggledentag').innerHTML = "hide tags"; } } function switchdenlist() { if (running) alert('please wait until the request is finished'); else { if (listtags == true) { listtags = false; nimmdenlist(); document.getElementById('switchdenlister').innerHTML = "show list of tags in area"; } else { listtags = true; gibdenlist(); document.getElementById('switchdenlister').innerHTML = "hide list of tags in area"; } } } //]]>