Google map ile koordinat ve adres bilgisi alma
Asagidaki ornekte google map uzerinden adres ve koordinat bilgisi alma bulunuyor bir gun bir yerde isinize yarayabilir :)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SBM Map</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
var address;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(41.091255,29.002876), 13);
map.setUIToDefault();
GEvent.addListener(map, "click", getAddress);
geocoder = new GClientGeocoder();
}
function getAddress(overlay, latlng) {
if (latlng != null) {
address = latlng;
geocoder.getLocations(latlng, showAddress);
}
}
function showAddress(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Status Code:" + response.Status.code);
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(
'<b>orig latlng:</b>' + response.name + '<br/> ' +
'<b>latlng:</b> ' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' +
'<b>Status Code:</b> ' + response.Status.code + '<br>' +
'<b>Status Request:</b> ' + response.Status.request + '<br>' +
'<b>Address:</b>' + place.address + '<br>' +
'<b>Accuracy:</b>' + place.AddressDetails.Accuracy + '<br>' +
'<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
document.getElementById('lat').value=place.Point.coordinates[1];
document.getElementById('lng').value=place.Point.coordinates[0];
document.getElementById('address').value=place.address;
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"/>
<form>
<table>
<tr>
<td>Lat :</td>
<td><input type="text" name="lat" id="lat"/> </td>
</tr>
<tr>
<td>Lng :</td>
<td><input type="text" name="lng" id="lng"/> </td>
</tr>
<tr>
<td>Adres :</td>
<td><textarea name="address" id="address" cols="40" rows="4"></textarea> </td>
</tr>
</table>
</form>
</body>
</html>
eline sağlık çok güzel olmuş…
çok iyi bir çalışma olmuş.
Benzerinin yalnızca posta kodunu bulanını geçenlerde yapmıştım, aynı kaynak :) http://test.ogulcan.org/zip