[html] Google map的地理编码javascript例子 -- Google map geocoder example

代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Google Maps API key for http://localhost/ [key] [googlemaps]</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
</head>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAnfs7bKE82qgb3Zc2YyS-oBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSySz_REpPq-4WZA27OwgbtyR3VcA"></script>
<script type="text/javascript">
function displayLatLng()
{
var geocoder = null;
geocoder
= new GClientGeocoder();
var addrObj = document.getElementById("address_63833");
var address = addrObj.value;
geocoder.getLatLng(
address,
function(point)
{
alert(point.lat());
alert(point.lng());
}
)
}

</script>
<body>
<input type="text" size="42" id="address_63833">
<input type="button" value="Find Address" id="button_63833" onclick="displayLatLng();" >
</body>
</html>

 

posted @ 2010-06-01 18:34  DavidHHuan  阅读(656)  评论(0编辑  收藏  举报