var map; var geocoder; var routeOrginal, routeTanken; var strecke1, strecke2; function load2() { map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(51.091714, 10.534584), 1); map.addControl(new GSmallMapControl()); geocoder = new GClientGeocoder(); map.setZoom(5); map.enableContinuousZoom(); addTankstellen(); routeOrginal = new GDirections(map); routeTanken = new GDirections(map); document.getElementById("von").value = document.getElementById("vonP").value; document.getElementById("nach").value = document.getElementById("nachP").value; GEvent.addListener(routeTanken,"load", formatTankRoute); GEvent.addListener(routeOrginal,"load", formatOrginalRoute); calcOrginalRoute(); } // addAddressToMap() is called when the geocoder returns an // answer. It adds a marker to the map with an open info window // showing the nicely formatted version of the address and the country code. function addAddressToMap(response) { map.clearOverlays(); if (!response || response.Status.code != 200) { alert("Leider konnten wir für die angegebene Adresse keine Geodaten erzeugen!"); } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); map.addOverlay(new GMarker(point)); map.setCenter(point,8); map.showMapBlowup(map.getCenter(),{zoomLevel:14}); // document.forms.newStation.gps1.value = point; } } // showLocation() is called when you click on the Search button // in the form. It geocodes the address entered into the form // and adds a marker to the map at that location. function showLocation() { var w = document.forms.newStation.ort.selectedIndex; var selected_text = document.forms.newStation.ort.options[w].text; var sel2 = selected_text.substr(6,500); document.getElementById("wikilink").href = "http://de.wikipedia.org/wiki/"+sel2; document.getElementById("wikilink").firstChild.nodeValue = "WikiLink zu "+sel2; var address = document.forms.newStation.strasse.value+" "+selected_text+" Deutschland"; geocoder.getLocations(address, addAddressToMap); return 0; } // für die Bilder teuer - bis billig function createMarker(point, text, bild, diff, size,id,beschr) { var icon = new GIcon(); icon.image = "http://www.kraftstoffweb.de/develop/2.0/pictures/"+bild; icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon.iconSize = new GSize(size, size); icon.shadowSize = new GSize(size, size); icon.iconAnchor = new GPoint(10, 20); icon.infoWindowAnchor = new GPoint(10, 10); var marker = new GMarker(point,icon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(text); var laenge; laenge = point.toString().length; // Zwischenstop einfügen document.forms["strecke"].ts.value = "@"+point.toString().substring(1,(laenge-1)); calcTankRoute(); // Umwegformular füllen document.forms["umwegForm"].differenz.value = diff; // Ausgewaehlte Tankstelle in Preisauswahl ebenfalls anwählen: if (document.getElementById("tankstellenID")) { document.getElementById("tankstellenID").value = id; document.getElementById("searchterm").value=beschr; } }); return marker; } function calcOrginalRoute() { var vonzu1; routeTanken.clear(); vonzu1 = "from:"+document.forms["strecke"].von.value+" to:"+document.forms["strecke"].nach.value; routeOrginal.load(vonzu1); } function calcTankRoute() { var vonzu2; vonzu2 = "from:"+document.forms["strecke"].von.value+" to:"+document.forms["strecke"].ts.value+" to:"+document.forms["strecke"].nach.value; routeTanken.load(vonzu2); } function formatOrginalRoute() { routeOrginal.getPolyline().setStrokeStyle({color: "#0000FF",opacity: 1,weight:4}); strecke1 = routeOrginal.getDistance().meters; } function formatTankRoute() { strecke2 = routeTanken.getDistance().meters; document.forms["umwegForm"].umweg.value = Math.round((strecke2-strecke1)/1000); calculate(); } function addTankstellen() { return 0;}