2. Juni 2010 07:50
<script src="http://maps.google.com/maps?file=api&v=2&key=//GOOGLE API KEY//" type="text/javascript"></script>
<div id="maps"></div>
<div id="directions"></div>
//Entfernung ermitteln
var map;
var directions;
map = new GMap2(document.getElementById("maps"));
directions = new GDirections(map, document.getElementById("directions")); setDirections(// STARTADRESSE//, // ZIELADRESSE//);
var km;
GEvent.addListener(directions, "load", function() {
km = directions.getDistance().meters/1000;
km = Math.round(km*100)/100;
crmForm.all.new_km1.DataValue = km.toString(); // AUSGABE DER KILOMETER IN DAS CRM FELD
});
var minuten;
GEvent.addListener(directions, "load", function() {
minuten = directions.getDuration().seconds/60;
minuten = Math.round(minuten*100)/100;
crmForm.all.new_fahrzeit1.DataValue = minuten.toString(); // AUSGABE DER MINUTEN IN DAS CRM FELD
});
function setDirections(fromAddress, toAddress) {
directions.load("from: " + fromAddress + " to: " + toAddress);
}
}
myGoogleURL = "http://maps.google.com/maps?f=d&source=s_d&saddr=" + crmForm.all.new_startpunkt.DataValue + "&daddr=" + myFirma1 + "+to:" + myFirma2 +"+to:" + myFirma3 + "+to:" + myFirma4 + "+to:" + crmForm.all.new_uebernachtung.DataValue + "&hl=de&output=embed&z=7"
document.getElementById("IFRAME_GMaps_d").innerHTML = "<iframe id=IFRAME_GMaps_d class=ms-crm-Custom width='100%' height='100%' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='"+ myGoogleURL +"'></iframe>";