// end Legend GMLegend.prototype = new GControl(); GMLegend.prototype.initialize = function(map) { var container =document.createElement("div"); var extra =document.createElement("div"); extra.className ="gmlegend"; extra.innerHTML =this.html; container.appendChild(extra); map.getContainer().appendChild(container); return container; }//--> end initialize GMLegend.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(6, 36)); }//--> end getDefaultPosition() function swapContent(params){ var show =params['show']; var hide =params['hide']; for(var i =0; i end for for(var i =0; i end for }//--> end swap tools; /** * * */ function showOrHideControl(params){ var type =params['type']; var caller =params['caller']; if(caller.checked ==false){ map.removeControl(type); }//--> end if else{ map.addControl(type); }//--> end else }//--> end showOrHideControl /** * This function shows or hides the makers selectet from the legend * * @param params :Array * */ function showOrHideMarkers(params) { var type =params['type']; var key =params['key']; var index =params['index']; map.closeInfoWindow(); switch(true){ case (type =='cat' && document.getElementById('boxLegendControl_'+key).checked ==false): for(var i=0;i end for break; case (type =='cat' && document.getElementById('boxLegendControl_'+key).checked ==true): for(var i=0;i end for break; case (type == 'subcat' && document.getElementById('boxLegendControl_'+key+'_'+index).checked==false): map.removeOverlay(markercategories[key]['markers'][index]); var allOff =true; for(var i=0;i end for document.getElementById('boxLegendControl_'+key).checked =!allOff; break; case (type == 'subcat' && document.getElementById('boxLegendControl_'+key+'_'+index).checked==true): if (document.getElementById('boxLegendControl_'+key).checked==false){ document.getElementById('boxLegendControl_'+key).checked =true; }//--> end if() map.addOverlay(markercategories[key]['markers'][index]); break; }//--> end switch }//-->end funtion /** * A function to create the marker and set up the event window * * @param point :GLatLng * @param name :String * @param html :String * @param cat :String * @param icon :String * * @param marker :GMarker * */ function createMarker(point, name, html, cat, catlabel, icon, url) { //createMarkerIcon(icon); var marker =new GMarker(point, createMarkerIcon(icon)); marker.point =point; marker.name =name; marker.cat =cat; marker.icon =icon; marker.count =markercount; marker.url =url; marker.html =html; if(markercategories[cat] ==null) { markercategories[cat] =new Object(); markercategories[cat]['label'] =catlabel; markercategories[cat]['markers'] =new Array(); }//--> end if(); markercategories[cat]['markers'].push(marker); gmarkers.push(marker); htmls.push(html); GEvent.addListener(marker, "click", function() { map.setCenter(marker.point,18,G_HYBRID_MAP); if(url ==null || url ==''){ marker.openInfoWindowHtml(html); }//--> end if else { marker.openInfoWindowHtml(html, {maxUrl:'assets/snippets/dp303gtours/ref.php?url='+url}); }//--> end else }); // add a line to the side_bar html //sideLegendHTML += '' + name + '
'; markercount++; return marker; }//--> end createMarker() /** * This function creates the markericon * * @param icoName :String; * */ function createMarkerIcon(icoName){ if(markericons[icoName] ==null){ var ico =new GIcon(); ico.image =getGMIconPath()+'icogm_'+icoName+'.png'; ico.printImage =getGMIconPath()+'icogm_'+icoName+'.gif'; ico.mozPrintImage =getGMIconPath()+'icogm_'+icoName+'.gif'; ico.shadow =getGMIconPath()+'icogm__shadow.png'; ico.transparent =getGMIconPath()+'icogm__trans.png'; ico.iconSize =new GSize(96,84); ico.iconAnchor =new GPoint(48,84); ico.shadowSize =new GSize(144,84); ico.infoShadowAnchor =new GPoint(70,30); ico.infoWindowAnchor =new GPoint(48,84); ico.imageMap =[47,84,28,37,28,23,32,17,35,14,39,12,43,10,53,10,57,12,61,14,64,17,68,23,68,37,48,84]; markericons[icoName] =ico; }//-->end if return markericons[icoName]; }//--> end createMarkerIcon /** * This function picks up the click and opens the corresponding info window * * @param i:Number */ function onHandleClick (type, markernum) { switch(true){ case (type =='sideLegendInner') : map.setCenter(gmarkers[markernum].point,18,G_HYBRID_MAP); if(gmarkers[markernum].url ==null || gmarkers[markernum].url ==''){ gmarkers[markernum].openInfoWindowHtml(gmarkers[markernum].html); }//--> end if else { gmarkers[markernum].openInfoWindowHtml(gmarkers[markernum].html, {maxUrl:'assets/snippets/dp303gtours/ref.php?url='+gmarkers[markernum].url}); }//--> end else break; }//--> end switch }//--> end myclick /* * This function just returns the iconpath * */ function getGMIconPath(){ return './assets/images/icogm/'; }//--> end getIconPath(); var request = GXmlHttp.create(); request.open("GET", "assets/snippets/dp303gtours/php/dp303gtourscore.php?r=xml&f="+xmlfile, true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = request.responseXML; // obtain the array of markers and loop through it var nodemeta =xmlDoc.documentElement.getElementsByTagName("metadata"); var nodemarkercategories =xmlDoc.documentElement.getElementsByTagName("markers"); var nodelines =xmlDoc.documentElement.getElementsByTagName("line"); // ====== The metadata ===== // var tourinfos =new Array(); tourinfos['name'] =nodemeta[0].getElementsByTagName('tour')[0].getAttribute('name'); tourinfos['tourlength'] =nodemeta[0].getElementsByTagName('tour')[0].getAttribute('tourlength'); tourinfos['uphill'] =nodemeta[0].getElementsByTagName('tour')[0].getAttribute('uphill'); tourinfos['downhill'] =nodemeta[0].getElementsByTagName('tour')[0].getAttribute('downhill'); var tourstart =new Array(); tourstart['lat'] =parseFloat(nodemeta[0].getElementsByTagName('tourstart')[0].getAttribute('lat')); tourstart['lng'] =parseFloat(nodemeta[0].getElementsByTagName('tourstart')[0].getAttribute('lng')); tourstart['ele'] =parseFloat(nodemeta[0].getElementsByTagName('tourstart')[0].getAttribute('ele')); tourstart['label'] =nodemeta[0].getElementsByTagName('tourstart')[0].getElementsByTagName('label')[0].firstChild.nodeValue; tourstart['sym'] =nodemeta[0].getElementsByTagName('tourstart')[0].getElementsByTagName('sym')[0].firstChild.nodeValue; tourstart['html'] =nodemeta[0].getElementsByTagName('tourstart')[0].getElementsByTagName('html')[0].firstChild.nodeValue; var tourend =new Array(); tourend['lat'] =parseFloat(nodemeta[0].getElementsByTagName('tourend')[0].getAttribute('lat')); tourend['lng'] =parseFloat(nodemeta[0].getElementsByTagName('tourend')[0].getAttribute('lng')); tourend['ele'] =parseFloat(nodemeta[0].getElementsByTagName('tourend')[0].getAttribute('ele')); tourend['label'] =nodemeta[0].getElementsByTagName('tourend')[0].getElementsByTagName('label')[0].firstChild.nodeValue; tourend['sym'] =nodemeta[0].getElementsByTagName('tourend')[0].getElementsByTagName('sym')[0].firstChild.nodeValue; tourend['html'] =nodemeta[0].getElementsByTagName('tourend')[0].getElementsByTagName('html')[0].firstChild.nodeValue; var highestpoint =new Array(); highestpoint['lat'] =parseFloat(nodemeta[0].getElementsByTagName('highestpoint')[0].getAttribute('lat')); highestpoint['lng'] =parseFloat(nodemeta[0].getElementsByTagName('highestpoint')[0].getAttribute('lng')); highestpoint['ele'] =parseFloat(nodemeta[0].getElementsByTagName('highestpoint')[0].getAttribute('ele')); highestpoint['label'] =nodemeta[0].getElementsByTagName('highestpoint')[0].getElementsByTagName('label')[0].firstChild.nodeValue; highestpoint['sym'] =nodemeta[0].getElementsByTagName('highestpoint')[0].getElementsByTagName('sym')[0].firstChild.nodeValue; highestpoint['html'] =nodemeta[0].getElementsByTagName('highestpoint')[0].getElementsByTagName('html')[0].firstChild.nodeValue; var deepestpoint =new Array(); deepestpoint['lat'] =parseFloat(nodemeta[0].getElementsByTagName('deepestpoint')[0].getAttribute('lat')); deepestpoint['lng'] =parseFloat(nodemeta[0].getElementsByTagName('deepestpoint')[0].getAttribute('lng')); deepestpoint['ele'] =parseFloat(nodemeta[0].getElementsByTagName('deepestpoint')[0].getAttribute('ele')); deepestpoint['label'] =nodemeta[0].getElementsByTagName('deepestpoint')[0].getElementsByTagName('label')[0].firstChild.nodeValue; deepestpoint['sym'] =nodemeta[0].getElementsByTagName('deepestpoint')[0].getElementsByTagName('sym')[0].firstChild.nodeValue; deepestpoint['html'] =nodemeta[0].getElementsByTagName('deepestpoint')[0].getElementsByTagName('html')[0].firstChild.nodeValue; var obounds =new Object(); obounds['minlat'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('minlat')); obounds['minlng'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('minlng')); obounds['minele'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('minele')); obounds['middlelat'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('middlelat')); obounds['middlelng'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('middlelng')); obounds['middleele'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('middleele')); obounds['maxlat'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('maxlat')); obounds['maxlng'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('maxlng')); obounds['maxlng'] =parseFloat(nodemeta[0].getElementsByTagName('bounds')[0].getAttribute('maxele')); if(!isNaN(tourstart['lat']) && !isNaN(tourstart['lng']) ){ var p =new GLatLng(tourstart['lat'], tourstart['lng']); var m =createMarker(p, tourstart['label'], tourstart['html'], 'tourinfos', 'Tourinfos', tourstart['sym']); map.addOverlay(m); }//--> end if if(!isNaN(tourend['lat']) && !isNaN(tourend['lng'])){ var p =new GLatLng(tourend['lat'], tourend['lng']); var m =createMarker(p, tourend['label'],tourend['html'], 'tourinfos', 'Tourinfos', tourend['sym']); map.addOverlay(m); }//--> end if if(!isNaN(highestpoint['lat']) && !isNaN(highestpoint['lng'])){ var p =new GLatLng(highestpoint['lat'], highestpoint['lng']); var m =createMarker(p, highestpoint['label'], highestpoint['html'], 'tourinfos', 'Tourinfos', highestpoint['sym']); map.addOverlay(m); }//--> end if if(!isNaN(deepestpoint['lat']) && !isNaN(deepestpoint['lng'])){ var p =new GLatLng(deepestpoint['lat'], deepestpoint['lng']); var m =createMarker(p, deepestpoint['label'], deepestpoint['html'], 'tourinfos', 'Tourinfos', deepestpoint['sym']); map.addOverlay(m); }//--> end if // ====== The markers ===== // for (var b = 0; b < nodemarkercategories.length; b++) { var nodemarkers =nodemarkercategories[b].getElementsByTagName("marker"); var curcategory =nodemarkercategories[b].getAttribute('cat'); var curcategoryl =nodemarkercategories[b].getAttribute('catlabel'); for(var ba=0; ba end for }//--> end for // ========= Now process the polylines =========== // read each line for (var c = 0; c < nodelines.length; c++) { // get any line attributes var color =nodelines[c].getAttribute("color"); var width =parseFloat(nodelines[c].getAttribute("width")); var alpha =parseFloat(nodelines[c].getAttribute("alpha")); // read each point on that line var points =nodelines[c].getElementsByTagName("point"); var linepts = []; for (var ca = 0; ca < points.length; ca++) { var p =new GLatLng(parseFloat(points[ca].getAttribute("lat")),parseFloat(points[ca].getAttribute("lng"))) bounds.extend(p); linepts[ca] =p; }//--> end for map.addOverlay(new GPolyline(linepts,color,width,alpha)); }//--> end for //Building the Legend var GMLegendHTML =new String(''); for(var key in markercategories){ var curlabel =markercategories[key]['label']; var curmarkers =markercategories[key]['markers']; GMLegendHTML +='
  • ' GMLegendHTML +='
      ' GMLegendHTML +='
    • '; //GMLegendHTML +=' '; GMLegendHTML +='   '+curlabel+'' GMLegendHTML +='
    • '; GMLegendHTML +=' '; GMLegendHTML +='
    • '; GMLegendHTML +='
        '; GMLegendHTML +='
      • '; GMLegendHTML +=' Alle Marker "'+curlabel+'"'; GMLegendHTML +='
      • '; for(var i=new Number(0); i '; GMLegendHTML +=' '+curmarker.icon+' '; GMLegendHTML +=' ' + curmarker.name + ''; GMLegendHTML +=''; }//--> end for(); GMLegendHTML +='
      '; GMLegendHTML +='
    • '; GMLegendHTML +='
    '; GMLegendHTML +='
  • '; }//--> end for var GMToolboxHTML =new String(''); GMToolboxHTML +='
    '; GMToolboxHTML +='
      ' GMToolboxHTML +='
    • Legende
    • '; GMToolboxHTML +='
    • ' GMToolboxHTML +='
        ' GMToolboxHTML +=GMLegendHTML; GMToolboxHTML +='
      ' GMToolboxHTML +='
    • ' GMToolboxHTML +='
    ' GMToolboxHTML +='
    ' mapLegendControl =new GMLegend(GMToolboxHTML); map.addControl(mapLegendControl); // ================================================ var MapControlsHTML ='Kartenzoom anzeigen   Kartentypen anzeigen   Massstab anzeigenKartentypen anzeigen   Legende anzeigen'; document.getElementById("mapcontrols").innerHTML = MapControlsHTML; //map.setZoom(map.getBoundsZoomLevel(bounds)); // ===== determine the centre from the bounds ====== var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2; var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2; map.setCenter(new GLatLng(clat,clng),map.getBoundsZoomLevel(bounds)); GEvent.addListener(map, "moveend", function() { if(map.getCenter() == mPoint){ map.setCenter(new GLatLng(clat,clng),map.getBoundsZoomLevel(bounds)); }//--> }); }//--> end if }//--> end function request.send(null); }//--> end if else { alert("Sorry, the Google Maps API is not compatible with this browser"); }//--> end else // This Javascript is based on code provided by the // Blackpool Community Church Javascript Team // http://www.commchurch.freeserve.co.uk/ // http://www.econym.demon.co.uk/googlemaps/ //]]>