简单的显示地图:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Google 地图 JavaScript API 示例: 地图标记</title> <mce:script src="http://ditu.google.cn/maps?file=api&v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=zh-CN" type="text/javascript"></mce:script> <mce:script type="text/javascript"><!-- function initialize() { if (GBrowserIsCompatible()) { var Gmap = new GMap2(document.getElementById("google_map")); var Glatlng = new GLatLng(36.841979367953016, 118.0594326423645); Gmap.setCenter(Glatlng, 14); var Gmarker = new GMarker(Glatlng); GEvent.addListener(Gmarker, "click", function() { var gHtml = "<b>地址:</b><br/>柳泉路 假日花园"; Gmap.openInfoWindowHtml(Glatlng, gHtml); }); Gmap.addOverlay(Gmarker); } } // --></mce:script> </head> <body οnlοad="initialize()" οnunlοad="GUnload()"> <div id="google_map" style="width: 500px; height: 300px"></div> </body> </html> 根据输入地址显示地图: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Google Maps API Example: Simple Geocoding</title> <mce:script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" mce_src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></mce:script> <mce:script type="text/javascript"><!-- var map = null; var geocoder = null; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); geocoder = new GClientGeocoder(); } } function showAddress(address) { if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(address); } } ); } } // --></mce:script> </head> <body οnlοad="initialize()" οnunlοad="GUnload()"> <form action="#" οnsubmit="showAddress(this.address.value); return false"> <p> <input type="text" size="60" name="address" value="1600 Amphitheatre Pky, Mountain View, CA" /> <input type="submit" value="Go!" /> </p> <div id="map_canvas" style="width: 500px; height: 300px"></div> </form> </body> </html> 一个可以参考的网站:http://www.js8.in/ 文章:http://www.js8.in/564.html