URL: https://www.overclockers.at/coding-stuff/xml_abfragen_und_verabeiten_202560/page_1 - zur Vollversion wechseln!
Ich hab auf meiner Website ein kleines Tool bei der man Mithilfe von GoogleMaps Sonnenauf- bzw Untergang und die Dauer der "Blauen Stunde" (zum Fotografieren) berechnen kann:Link
Man muss aber die Zeitverschiebung für die bestimmten Regionen wissen und manuell eingeben. Daher will ich eine automatische Abfrage der Zeitzonen einbauen.
Das ganze funktioniert mit folgender Abfrage an http://www.earthtools.org:
Code:http://www.earthtools.org/timezone/<latitude>/<longitude>
Code:<?xml version="1.0" encoding="ISO-8859-1" ?> <timezone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.earthtools.org/timezone.xsd"> <version>1.1</version> <location> <latitude>40.71417</latitude> <longitude>-74.00639</longitude> </location> <offset>-5</offset> <suffix>R</suffix> <localtime>4 Dec 2005 12:06:56</localtime> <isotime>2005-12-04 12:06:56 -0500</isotime> <utctime>2005-12-04 17:06:56</utctime> <dst>False</dst> </timezone>
Code:<!-- Google MAPS Start//--> <body onLoad="initialize()" onUnload="GUnload()"> <div id="map" style="width: 800px; height: 600px"></div> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA18xUzGiAFw1_qthQ65HNTRTKeqUuFW5TJc31OzJwOz8k-MZiIRQ_1kTRxQE6-X4_N3HN9mXgc22tEA" type="text/javascript"></script> <script type="text/javascript"> function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); var center = new GLatLng(48.2, 16.3); map.setCenter(center, 8); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.addControl(new GOverviewMapControl(new GSize(130,110))); map.addControl(new GScaleControl()); map.enableScrollWheelZoom(); map.enableContinuousZoom(); var marker = new GMarker(center, {draggable: true}); GEvent.addListener(marker, "dragstart", function() { map.closeInfoWindow(); }); GEvent.addListener(marker, "dragend", function() { document.getElementById('lat').value = marker.getPoint().lat(); document.getElementById('lng').value = marker.getPoint().lng(); document.getElementById('offset').src="http://www.earthtools.org/timezone/'lat'/'lng'"; }); map.addOverlay(marker); } } </script> <!--Berechnung für Test gelöscht--> <FORM NAME="Input"> <table width="100%" border="0" cellspacing="0" cellpadding="1"> <tr> <td class="bordercolor"> <table width="800" border="0" cellpadding="3" cellspacing="0"> <tr class="head1"> <td colspan="2" class="head1">Eingabe</td> </tr> <tr class="row1"> <td width="380"><strong>Geografische Länge</strong> </td> <td><input name="Lon" type="text" class="searchinput" id="lng" size="21" /> </td> </tr> <tr class="row2"> <td width="380"><strong>Geografische Breite </strong></td> <td><input name="Lat" type="text" class="searchinput" id="lat" size="21" /> <tr class="row3"> <td width="380"><strong>Zeitverschiebung </strong></td> <td><input name="Zeitverschiebung" type="text" class="searchinput" id="offset" size="21" /> </FORM>
Da wirst du einen XMLHTTPRequest machen müssen und das Ergebnis via DOM auswerten. Ist nicht allzu kompliziert.
Zitat von thatDa wirst du einen XMLHTTPRequest machen müssen und das Ergebnis via DOM auswerten. Ist nicht allzu kompliziert.
overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2025