Anfahrt

Von:    Nach: 
Sprache: 

Karte

Formatierte Ausgabe


Commodo dolor lectorum

Commodo dolor lectorum facer tation clari. Iis nisl ut eu consectetuer dolor. Est esse nulla ut ut legentis. Illum possim ad ipsum quam dignissim. Possim eodem etiam usus saepius et. Dolor eorum tempor decima eros lectores. Ex quam praesent videntur mazim vulputate. Tation eu typi eros facilisi assum. Nunc facilisis quam putamus et hendrerit. Vel wisi sollemnes velit consequat ad.


Die Einbindung dieser Karte:

Siehe davor Voraussetzung

1. In benutzerdefinierten Kopfzeilen-Feld diesen Code eingeben:

<script type="text/javascript"> 
//<![CDATA[ 
var map;
var gdir;

function initialize() {
  if (GBrowserIsCompatible()) {      
    map = new GMap2(document.getElementById("map_canvas"));
    gdir = new GDirections(map, document.getElementById("directions"));
    GEvent.addListener(gdir, "error", handleErrors);
    GEvent.addListener(gdir, "addoverlay", onGDirectionsAddOverlay); // Triggers marker swap, Esa
    map.setCenter(new GLatLng(0,0),0);	// inital setCenter()  added by Esa.
    setDirections("Köln", "Frankfurt am Main", "de_DE");
    // api version display added by Esa
    document.getElementById("api-v").innerHTML = '2.'+G_API_VERSION;
  }
}

function setDirections(fromAddress, toAddress, locale) {
  gdir.load("from: " + fromAddress + " to: " + toAddress,
  { "locale": locale , "getSteps":true});
}

function handleErrors(){
  if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
    alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
  else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
    alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
  else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
    alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
  else if (gdir.getStatus().code == G_GEO_BAD_KEY)
    alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
  else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
    alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
  else alert("An unknown error occurred.");
}
  
///////////////////////////////////////////////////////////////////////

/**
* The add-on code for draggable markers
* @author Esa 2008
*/
var newMarkers = [];
var latLngs = [];
var icons = [];

// Note the 'addoverlay' GEvent listener inside initialize() function of the original code (above).
// 'load' event cannot be used

function onGDirectionsAddOverlay(){ 
  // Remove the draggable markers from previous function call.
  for (var i=0; i<newMarkers.length; i++){
    map.removeOverlay(newMarkers[i]);
  }

  // Loop through the markers and create draggable copies
  for (var i=0; i<=gdir.getNumRoutes(); i++){
    var originalMarker = gdir.getMarker(i);
    latLngs[i] = originalMarker.getLatLng();
    icons[i] = originalMarker.getIcon();
    newMarkers[i] = new GMarker(latLngs[i],{icon:icons[i], draggable:true, title:'Draggable'});
    map.addOverlay(newMarkers[i]);

    // Get the new waypoints from the newMarkers array and call loadFromWaypoints by dragend
    GEvent.addListener(newMarkers[i], "dragend", function(){
      var points = [];
      for (var i=0; i<newMarkers.length; i++){
        points[i]= newMarkers[i].getLatLng();
      }
      gdir.loadFromWaypoints(points);
    });

    //Bind 'click' event to original markers 'click' event
    copyClick(newMarkers[i],originalMarker);

    // Now we can remove the original marker safely
    map.removeOverlay(originalMarker);
  }

  function copyClick(newMarker,oldMarker){
    GEvent.addListener(newMarker, 'click', function(){
      GEvent.trigger(oldMarker,'click');
    });
  }
}
window.onload = initialize;
window.onunload = GUnload;
//]]> 
</script>

2. In einer HTML Seite diesen Code eingeben:

<div class="richtungen">
	<div class="ZweiSpaltenHeader">
		<h2>
			Anfahrt
		</h2>
		<form action="#" onsubmit="setDirections(this.from.value, this.to.value, this.locale.value); return false">
			<table>
				<tr>
					<th align="right">
						Von:&nbsp;
					</th>
					<td>
						<input type="text" size="25" id="fromAddress" name="from" value="Köln">
					</td>
					<th align="right">
						&nbsp;&nbsp;Nach:&nbsp;
					</th>
					<td align="right">
						<input type="text" size="25" id="toAddress" name="to" value="Frankfurt am Main">
					</td>
				</tr>
				<tr>
					<th>
						Sprache:&nbsp;
					</th>
					<td colspan="3">
						<select id="locale" name="locale">
							<option value="de" selected>
								German
							</option>
							<option value="en">
								English
							</option>
							<option value="fr">
								French
							</option>
							<option value="ja">
								Japanese
							</option>
							<option value="es">
								Spanish
							</option>
							<option value="fi">
								Finnish
							</option>
						</select> <input name="submit" type="submit" value="Zeige die Route">
					</td>
				</tr>
			</table>
		</form>
		<br />
	</div>
	<div style="width: 47%; float: left;">
		<h3>
			Karte
		</h3>
		<div id="map_canvas" style="height: 500px"></div>
	</div>
	<div style="margin-left: 53%;">
		<h3>
			Formatierte Ausgabe
		</h3>
		<div id="directions"></div>
	</div>
	<div class="ZweiSpaltenFooter" style="clear: both;">
		<br>
		<h3>
			Commodo dolor lectorum
		</h3>
		<p>
			Commodo dolor lectorum facer tation clari. Iis nisl ut eu consectetuer dolor. Est esse nulla ut ut legentis. Illum possim ad ipsum quam dignissim. Possim eodem etiam usus saepius et. Dolor eorum tempor decima eros lectores. Ex quam praesent videntur mazim vulputate. Tation eu typi eros facilisi assum. Nunc facilisis quam putamus et hendrerit. Vel wisi sollemnes velit consequat ad.
		</p>
	</div>
</div>
<noscript>
	<strong>JavaScript muss aktiviert sein um Google Maps zu nutzen.</strong> Es scheint jedoch, dass JavaScript entweder deaktiviert ist oder von Ihrem Browser nicht unterstützt wird. Um Google Maps anzuzeigen aktivieren Sie JavaScript in den Browser-Optionen und versuchen Sie es dann erneut.
</noscript>