Herzlich willkommen im Archiv vom ABAKUS Online Marketing Forum
Du befindest Dich im Archiv vom ABAKUS Online Marketing Forum. Hier kannst Du Dich für das Forum mit den aktuellen Beiträgen registrieren.
Code: Alles auswählen
function copylatlon() {
var wert = document.getElementById('latlon');
var werte = wert.split(',');
document.getElementById('lat').value = werte[0];
document.getElementById('lon').value = werte[1];
}
Code: Alles auswählen
<form name='submit' action='index.php?a=edit&e=geo' method='post' onsubmit="copylatlon(); return false;">
Code: Alles auswählen
<?
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
\"http://www.w3.org/TR/html4/strict.dtd\">
<html>
<head>
<title>Get Lat Lon - find the latitude and longitude of a point on a map</title>
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">
<style type=\"text/css\">
body {
margin: 0;
margin-bottom: 3em;
padding: 0;
font-family: \"Gill sans\", sans-serif;
background-color: #fff;
color: #000;
}
div#hd {
text-align: center;
border-bottom: 2px solid black;
}
div#hd h1 {
margin-bottom: 0;
font-size: 1.5em;
}
div#ft {
border-top: 2px solid black;
}
div#ft p {
width: 500px;
margin: 1em auto;
}
p#builtby {
font-size: 0.8em;
text-align: right;
color: #666;
}
div#bd {
position: relative;
}
div#gmap {
width: 550px;
height: 400px; /* If you change this don't forget to change the crosshair position to match */
}
div#crosshair {
position: absolute;
top: 192px;
height: 19px;
width: 19px;
left: 50%;
margin-left: -8px;
display: block;
background: url(crosshair.gif);
background-position: center center;
background-repeat: no-repeat;
}
</style>
<script src=\"http://www.google.com/jsapi?key=[API-KEY]\" type=\"text/javascript\">
</script>
<script type=\"text/javascript\">
google.load('maps', '2'); // Load version 2 of the Maps API
function timezoneLoaded(obj) {
var timezone = obj.timezoneId;
if (!timezone) {
return;
}
document.getElementById('timezone').innerHTML = timezone;
document.getElementById('timezonep').style.display = 'block';
// Find out what time it is there
var s = document.createElement('script');
s.src = \"http://json-time.appspot.com/time.json?callback=timeLoaded&tz=\" + timezone;
s.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(s);
}
function timeLoaded(obj) {
if (obj.datetime) {
document.getElementById('datetime').innerHTML = obj.datetime;
document.getElementById('datetimep').style.display = 'block';
}
}
function showMap() {
window.gmap = new google.maps.Map2(document.getElementById('gmap'));
gmap.addControl(new google.maps.LargeMapControl());
gmap.addControl(new google.maps.MapTypeControl());
gmap.enableContinuousZoom();
gmap.enableScrollWheelZoom();
var timer = null;
google.maps.Event.addListener(gmap, \"move\", function() {
var center = gmap.getCenter();
document.getElementById(\"latlon\").innerHTML = center.toString();
// Wait a second, then figure out the timezone
if (timer) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout(function() {
document.getElementById('timezonep').style.display = 'none';
document.getElementById('datetimep').style.display = 'none';
// Look up the timezone using geonames
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = \"http://ws.geonames.org/timezoneJSON?lat=\" + center.lat() +
\"&lng=\" + center.lng() + \"&callback=timezoneLoaded\";
document.getElementsByTagName(\"head\")[0].appendChild(s);
}, 1500);
});
google.maps.Event.addListener(gmap, \"zoomend\", function(oldZoom, newZoom) {
document.getElementById(\"zoom\").innerHTML = newZoom;
});
google.maps.Event.addDomListener(document.getElementById('crosshair'),
'dblclick', function() {
gmap.zoomIn();
}
);
// Default view of the world
gmap.setCenter(
new google.maps.LatLng(43.834526782236814, -37.265625), 5
);
/* If we have a best-guess for the user's location based on their IP,
show a \"zoom to my location\" link */
if (google.loader.ClientLocation) {
var link = document.createElement('a');
link.onclick = function() {
gmap.setCenter(
new google.maps.LatLng(
google.loader.ClientLocation.latitude,
google.loader.ClientLocation.longitude
), 8
);
return false;
}
link.href = '#'
link.appendChild(
document.createTextNode('Zoom to my location (by IP)')
);
var form = document.getElementById('geocodeForm');
var p = form.getElementsByTagName('p')[0];
p.appendChild(link);
}
// Set up Geocoder
window.geocoder = new google.maps.ClientGeocoder();
// If query string was provided, geocode it
var bits = window.location.href.split('?');
if (bits[1]) {
var location = decodeURI(bits[1]);
document.getElementById('geocodeInput').value = location;
geocode(location);
}
// Set up the form
var geocodeForm = document.getElementById('geocodeForm');
geocodeForm.onsubmit = function() {
geocode(document.getElementById('geocodeInput').value);
return false;
}
}
var accuracyToZoomLevel = [
1, // 0 - Unknown location
5, // 1 - Country
6, // 2 - Region (state, province, prefecture, etc.)
8, // 3 - Sub-region (county, municipality, etc.)
11, // 4 - Town (city, village)
13, // 5 - Post code (zip code)
15, // 6 - Street
16, // 7 - Intersection
17 // 8 - Address
];
function geocodeComplete(result) {
if (result.Status.code != 200) {
alert('Could not geocode \"' + result.name + '\"');
return;
}
var placemark = result.Placemark[0]; // Only use first result
var accuracy = placemark.AddressDetails.Accuracy;
var zoomLevel = accuracyToZoomLevel[accuracy] || 1;
var lon = placemark.Point.coordinates[0];
var lat = placemark.Point.coordinates[1];
var centreMarker = null; var centreIcon=new GIcon();centreIcon.image=\"/crosshair.gif\";centreIcon.shadow=\"\";centreIcon.iconSize=new GSize(17, 17);centreIcon.shadowSize=new GSize(0,0);centreIcon.iconAnchor=new GPoint(9,9);centreIcon.infoWindowAnchor=new GPoint(5,1);
gmap.setCenter(new google.maps.LatLng(lat, lon), zoomLevel);
}
function geocode(location) {
geocoder.getLocations(location, geocodeComplete);
}
function copylatlon() {
var wert = document.getElementById('latlon');
var werte = wert.split(',');
document.getElementById('lat').value = werte[0];
document.getElementById('lon').value = werte[1];
}
google.setOnLoadCallback(showMap);
</script>
</head>
<body>
<div id=\"hd\">
</div>
<div id=\"bd\">
<div id=\"gmap\"></div>
<div id=\"crosshair\"></div>
</div>
<div id=\"ft\"align=LEFT>
Latitude, Longitude: <strong><span id=\"latlon\"></span></strong><br>
Google Maps zoom level: <span id=\"zoom\"></span><br>
</div>
<form name='submit' action='geo.php' method='get' onsubmit=\"copylatlon(); return false;\">
<input type='hidden' id='lat' name='lat'>
<input type='hidden' id='lon' name='lon'>
<input type='submit' value='Submit' name='submit'>
</form>
</body>
</html>";
?>
Code: Alles auswählen
geo.php?lat=&lon=&submit=Submit
Code: Alles auswählen
function geocodeComplete(result) {
if (result.Status.code != 200) {
alert('Could not geocode \"' + result.name + '\"');
return;
}
var placemark = result.Placemark[0]; // Only use first result
var accuracy = placemark.AddressDetails.Accuracy;
var zoomLevel = accuracyToZoomLevel[accuracy] || 1;
var lon = placemark.Point.coordinates[0];
var lat = placemark.Point.coordinates[1];
// hier:
document.getElementById('lat').value = lat;
document.getElementById('lon').value = lon;
var centreMarker = null; var centreIcon=new GIcon();centreIcon.image=\"/crosshair.gif\";centreIcon.shadow=\"\";centreIcon.iconSize=new GSize(17, 17);centreIcon.shadowSize=new GSize(0,0);centreIcon.iconAnchor=new GPoint(9,9);centreIcon.infoWindowAnchor=new GPoint(5,1);
gmap.setCenter(new google.maps.LatLng(lat, lon), zoomLevel);
}
Code: Alles auswählen
var wert = document.getElementById('latlon');
Code: Alles auswählen
var wert = document.getElementById('latlon'),innerHTML;
Code: Alles auswählen
function copylatlon() {
var wert = document.getElementById('latlon').innerHTML;
var werte = wert.split(',');
lat_cut = werte[0].substring(1,werte[0].length);
lon_cut = werte[1].substring(0,werte[1].length-1);
document.getElementById('lat').value = lat_cut;
document.getElementById('lon').value = lon_cut;
}
Eigentlich war das als kleine Denksportaufgabe gedachtok, das habe ich nun auch geschafft, nun muss das nurnoch abgeschickt werden, weiss einer warum das nicht funktioniert?
Beim knopfdruck werden die Felder befüllt und dann passiert nichts...