From 4c98da1ceff06e565a8e85e395c747b28edef19d Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 29 Dec 2013 20:38:59 +0000 Subject: moved map3.js to map.js --- map.js | 855 ++++++++++++++++++++++++++++++----------------------------------- 1 file changed, 391 insertions(+), 464 deletions(-) (limited to 'map.js') diff --git a/map.js b/map.js index e51aea5..b60b7f0 100644 --- a/map.js +++ b/map.js @@ -1,160 +1,107 @@ var map = null; var linkinfo; -var physicalMaxLevel; var geocoder = null; var reloadcon = null; var countboxText = null; var overlays = new Array(); -overlays["new"] = null; +overlays["newmarker"] = null; overlays["ruler"] = new Array(); overlays["locations"] = new Array(); overlays["links"] = new Array(); var locations = new Array(); var links = new Array(); + +debug = function (log_txt) { + if (typeof window.console != 'undefined') { + console.log(log_txt); + } +} + function initialize(lat, lng, res) { - if (!checkBrowser()) { - return; - } - - map = new GMap2(document.getElementById("map")); - map.setCenter(new GLatLng(lat, lng), res); - map.disableDoubleClickZoom(); - map.enableScrollWheelZoom(); - -// map.removeMapType(G_HYBRID_MAP); -// map.removeMapType(G_SATELLITE_MAP); - map.addMapType(G_PHYSICAL_MAP); -// map.setMapType(G_HYBRID_MAP); - - // openStreetMap - var copyOSM = new GCopyrightCollection("OpenStreetMap"); - var copyOGDGraz = new GCopyrightCollection("Open Government Data Graz"); - copyOSM.addCopyright(new GCopyright(1, new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)), 0, " ")); - var tilesOsmarender = new GTileLayer(copyOSM, 1, 17, {tileUrlTemplate: 'http://tah.openstreetmap.org/Tiles/tile/{Z}/{X}/{Y}.png'}); - var mapOsmarender = new GMapType([tilesOsmarender], G_NORMAL_MAP.getProjection(), "openSM", {urlArg: 'y'}); - map.addMapType(mapOsmarender); - var tilesMapnik = new GTileLayer(copyOSM, 1, 17, {tileUrlTemplate: 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png'}); - var mapMapnik = new GMapType([tilesMapnik], G_NORMAL_MAP.getProjection(), "Mapnik", {urlArg: 'x'}); - map.addMapType(mapMapnik); -// var tilesOpenGeoServer = new GTileLayer(copyOGDGraz, 1, 17, {tileUrlTemplate: 'http://services.opengeoserver.org/tiles/1.0.0/globe.aerial_EPSG3857/${Z}/${X}/${Y}.png?origin=nw'}); -// var mapOpenGeoServer = new GMapType([tilesOpenGeoServer], G_NORMAL_MAP.getProjection(), "OpenGeoServer"); -// map.addMapType(mapOpenGeoServer); - - physicalMaxLevel = map.getCurrentMapType().getMaximumResolution(); - if(res > physicalMaxLevel) { - map.setMapType(G_NORMAL_MAP); - map.setZoom(res); - } - map.addControl(new RulerControl()); - reloadcon = new ReloadControl(); - map.addControl(reloadcon); - map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,20))); - map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50,10))); - - GEvent.addListener(map, "addoverlay", onAddOverlay); - GEvent.addListener(map, "zoomend", onZoom); - GEvent.addListener(map, "click", onMapClick); - + debug("Initializing Funkfeuer Graz Map"); + $('#southeastcontainer').hide(); + + google.maps.visualRefresh=true; + var mapOptions = { + center: new google.maps.LatLng(lat, lng), + zoom: res, + streetViewControl: false, + mapTypeId: google.maps.MapTypeId.ROADMAP, + mapTypeControlOptions: { + mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID , google.maps.MapTypeId.SATELLITE , google.maps.MapTypeId.TERRAIN ], + style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, + } + }; + map = new google.maps.Map(document.getElementById("map"), + mapOptions); +//##// deaktiviert 2013112 goole maps api v3 incompatibel +//##// map.disableDoubleClickZoom(); + +//##// map.addControl(new RulerControl()); +//##// reloadcon = new reloadcontrol(); +//##// map.addcontrol(reloadcon); +//##// map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,20))); +//##// map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50,10))); + + google.maps.event.addListener(map, "click", onMapClick); + lineinfo = document.createElement("div"); document.getElementById("map").appendChild(lineinfo); lineinfo.style.visibility = "hidden" - + dnsinfo = document.createElement("div"); document.getElementById("map").appendChild(dnsinfo); dnsinfo.style.visibility = "hidden" - - var mt = map.getMapTypes(); - for (var i=0; i physicalMaxLevel) { - // map.setMapType(G_SATELLITE_MAP); - } +//##// reloadcon.started(); + $.get( "data.php",onData); } -function onMapClick(overlay, point) +function onMapClick(mouse_event) { - if(!overlay) { - map.setCenter(point); - setNewMarker(point); - } + map.setCenter(mouse_event.latLng); + setNewMarker(mouse_event.latLng); } -function onData(data, responseCode) { - if (responseCode < 200 || responseCode > 299) { - reloadcon.finished(); - return alert("Fehler: Konnte die Daten nicht laden!\n(Server Antwort-Code: " + responseCode + ")"); - } - reloadcon.loaded(); - xmlData = GXml.parse(data); - +//##//function onData(data, responseCode) { +//##// if (responseCode < 200 || responseCode > 299) { +//##// reloadcon.finished(); +//##// return alert("Fehler: Konnte die Daten nicht laden!\n(Server Antwort-Code: " + responseCode + ")"); +//##// } +//##// reloadcon.loaded(); +function onData(xmlData) { for(var loc in overlays["locations"]) { - map.removeOverlay(overlays["locations"][loc]); + overlays["locations"][loc].setMap(null); } overlays["locations"] = []; locations = []; - drawLocations(xmlData); + if (xmlData) { + drawLocations(xmlData); + } for(var link in overlays["links"]) { - map.removeOverlay(overlays["links"][link]); + overlays["links"][link].setMap(null); } overlays["links"] = []; links = []; - drawLinks(xmlData); + if (xmlData) { + drawLinks(xmlData); + } + + if (xmlData) { + var element = xmlData.getElementsByTagName("count"); + var count = element[0].getAttribute("number"); + countboxText.data = "Aktiv: " + count; + } - var element = xmlData.getElementsByTagName("count"); - var count = element[0].getAttribute("number"); - countboxText.data = "Aktiv: " + count; - - reloadcon.finished(); +//##// reloadcon.finished(); } function drawLocations(xmlData) { @@ -163,11 +110,12 @@ function drawLocations(xmlData) { var id = parseInt(element[i].getAttribute("id")); locations[id] = new Location(element[i]); - var marker = new GMarker(locations[id].point, {icon: makeIcon(locations[id].state)}); + var marker = new google.maps.Marker({position: locations[id].point, icon: makeIcon(locations[id].state)}); marker.overlaytype = "location"; marker.locid = id; - GEvent.addListener(marker, "click", onLocationClick); - map.addOverlay(marker); + google.maps.event.addListener(marker, "click", onLocationClick); + marker.setMap(map); + overlays["locations"].push(marker); } if(document.visibleform.elements["offline"].checked) { toggleVisible("offline"); @@ -182,7 +130,7 @@ function Location(element) { location.name = element.getAttribute("name"); var lat = parseFloat(element.getAttribute("lat")); var lng = parseFloat(element.getAttribute("lng")); - location.point = new GLatLng(lat, lng); + location.point = new google.maps.LatLng(lat, lng); location.pixel_x = parseInt(element.getAttribute("pixel_x")); location.pixel_y = parseInt(element.getAttribute("pixel_y")); location.state = element.getAttribute("state"); @@ -194,10 +142,10 @@ function Location(element) { function onLocationClick(latlng) { var html = '
'; - html += '' + locations[this.locid].name + ''; + html += '' + locations[this.locid].name + ''; html += ''; - html += ''; - html += ''; + html += ''; + html += ''; html += ''; html += ''; if(locations[this.locid].gallery_link) { @@ -216,44 +164,12 @@ function onLocationClick(latlng) { } html += ''; } - } - } - html += '
Breitengrad: ' + convertCoords(locations[this.locid].point.lat()) + '
Längengrad: ' + convertCoords(locations[this.locid].point.lng()) + '
Breitengrad: ' + convertCoords(locations[this.locid].point.lat()) + '
' + locations[this.locid].point.lat().toFixed(6) + '
Längengrad: ' + convertCoords(locations[this.locid].point.lng()) + '
' + locations[this.locid].point.lng().toFixed(6) + '
Datenbank: Link-Database
Smokeping: Link-Smokeping
Router: '+dnsname[i]+'
'; - html += '
'; - this.openInfoWindowHtml(html); -} - -function onLineClick(line,latlng) { -// var html ='