이것은 테스트 페이지에서 사용하는 간단한 코드입니다.하지만 주소를 찾는 데는 시간이 걸립니다. 어떻게 하죠? 내가 뭐 잘못하고있는거야?지리적 위치가 너무 느립니다! 내가 뭘 잘못하고있어?
<script src="http://maps.google.com/maps?hl=it&file=api&v=2&sensor=true&key=*xxxxxx*" type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
function addAddressToMap(response)
{
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode that address");
}
else
{
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
document.getElementById('address').innerHTML = place.address;
}
}
function searchGeolocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(function(position)
{
geocoder = new GClientGeocoder();
document.getElementById('latitude').innerHTML = position.coords.latitude;
document.getElementById('longitude').innerHTML = position.coords.longitude;
coordinates = position.coords.latitude+","+position.coords.longitude;
geocoder.getLocations(coordinates, addAddressToMap);
});
}else
{
document.getElementById('latitude').innerHTML = "Unknown";
document.getElementById('longitude').innerHTML = "Unknown";
document.getElementById('address').innerHTML = "Unknown";
alert("I'm sorry, but geolocation services are not supported by your browser.");
}
}
</script>
<br/>
latitude = <div id="latitude">loading...</div>
<br/>
longitude = <div id="longitude">loading...</div>
<br/>
address = <div id="address">loading...</div>
<br/>
<script type="text/javascript">
searchGeolocation();
</script>
어디 html5입니까? –
복용 기간은 얼마나됩니까? 한 번에 많은 수의 조회를 수행하지 않는다고 가정합니다. – LarsH
@Shawn :'navigator.geolocation.getCurrentPosition' 비트 : http://www.w3.org/TR/geolocation-API/ 예, 용어는 약간 부정확하지만 의미가 분명합니다. –