From 9f28da4440bfcea17490dc2f3a6ac900c762cfbd Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Tue, 12 Nov 2013 20:21:09 +0000 Subject: added alternative version with google maps api v3. very basic support without the possibility to add new nodes --- map3.js | 856 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 856 insertions(+) create mode 100644 map3.js (limited to 'map3.js') diff --git a/map3.js b/map3.js new file mode 100644 index 0000000..eff52d1 --- /dev/null +++ b/map3.js @@ -0,0 +1,856 @@ +var map = null; +var linkinfo; +var physicalMaxLevel; +var geocoder = null; +//##//var reloadcon = null; +var countboxText = null; +var overlays = new Array(); +overlays["new"] = null; +overlays["ruler"] = new Array(); +overlays["locations"] = new Array(); +overlays["links"] = new Array(); +var locations = new Array(); +var links = new Array(); +var lines = new Array(); +var markers = new Array(); + +function initialize(lat, lng, res) { + if (!checkBrowser()) { + return; + } + $('#visibox').hide(); + $('#southeastcontainer').hide(); + google.maps.visualRefresh=true; + var mapOptions = { + center: new google.maps.LatLng(lat, lng), + zoom: res, + 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); +//##// map.disableDoubleClickZoom(); +//##// map.enableScrollWheelZoom(); + +// map.removeMapType(G_HYBRID_MAP); +// map.removeMapType(G_SATELLITE_MAP); +//##// map.addMapType(G_PHYSICAL_MAP); +// map.setMapType(G_HYBRID_MAP); + +//##// deaktiviert 2013112 goole maps api v3 incompatibel +//##// // openStreetMap +//##// var copyOSM = new GCopyrightCollection("OpenStreetMap"); +//##// var copyOGDGraz = new GCopyrightCollection("Open Government Data Graz"); +//##// copyOSM.addCopyright(new GCopyright(1, new GLatLngBounds(new google.maps.LatLng(-90,-180), new google.maps.LatLng(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))); + + google.maps.event.addListener(map, "addoverlay", onAddOverlay); + google.maps.event.addListener(map, "zoomend", onZoom); + 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); + } +} + +function onMapClick(overlay, point) +{ + if(!overlay) { + map.setCenter(point); + setNewMarker(point); + } +} + +//##//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(data) { +//##// xmlData = GXml.parse(data); +//##//alert("Data Loaded: " +data.slice( 0, 100 )); + //##//xmlData = $.parseXML(data.responseText); + xmlData = data; + + for(var loc in overlays["locations"]) { + map.removeOverlay(overlays["locations"][loc]); + } + overlays["locations"] = []; + locations = []; + if (xmlData) { + drawLocations(xmlData); + } + + for(var link in overlays["links"]) { + map.removeOverlay(overlays["links"][link]); + } + overlays["links"] = []; + links = []; + if (xmlData) { + drawLinks(xmlData); + } + + if (xmlData) { + var element = xmlData.getElementsByTagName("count"); + var count = element[0].getAttribute("number"); + countboxText.data = "Aktiv: " + count; + } + +//##// reloadcon.finished(); +} + +function drawLocations(xmlData) { + var element = xmlData.getElementsByTagName("node"); + for (var i = 0; i< element.length; i++) { + var id = parseInt(element[i].getAttribute("id")); + locations[id] = new Location(element[i]); + + var marker = new google.maps.Marker({position: locations[id].point, icon: makeIcon(locations[id].state)}); + marker.overlaytype = "location"; + marker.locid = id; + google.maps.event.addListener(marker, "click", onLocationClick); +//##// map.addOverlay(marker); + marker.setMap(map); + markers.push(marker); + } + if(document.visibleform.elements["offline"].checked) { + toggleVisible("offline"); + } + if(document.visibleform.elements["online"].checked) { + toggleVisible("online"); + } +} + +function Location(element) { + var location = new Object(); + location.name = element.getAttribute("name"); + var lat = parseFloat(element.getAttribute("lat")); + var lng = parseFloat(element.getAttribute("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"); + location.gallery_link = element.getAttribute("gallery_link"); + location.dnsnames = element.getAttribute("router_links"); + + return location; +} + +function onLocationClick(latlng) { + var html = '
'; + html += '' + locations[this.locid].name + ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + if(locations[this.locid].gallery_link) { + html += ''; + } else { + html += ''; + } + if (locations[this.locid].dnsnames){ + var dnsname = locations[this.locid].dnsnames.split(";"); + for (var i = 0;i < dnsname.length; ++i){ + if (dnsname[i]!==""){ + if(dnsname[i].indexOf(" (")>=0) { + link=dnsname[i].substring(0,dnsname[i].indexOf(" (")); + } else { + link=dnsname[i]; + } + html += ''; + } + } + } + html += '
Breitengrad: ' + convertCoords(locations[this.locid].point.lat()) + '
Längengrad: ' + convertCoords(locations[this.locid].point.lng()) + '
Datenbank: Link-Database
Smokeping: Link-Smokeping
Galerie: Link-Galerie/Knoten
Galerie: Link-Galerie
Router: '+dnsname[i]+'
'; + html += '
'; + var infowindow = new google.maps.InfoWindow({ + content: html + }); + infowindow.open(map,this); +//##// this.openInfoWindowHtml(html); +} + +function onLineClick(line,latlng) { +// var html ='