http://tianjin.fantong.com/cate/700000926/ 看看这个代码拿来就能用 哦这个是51地图的 google的需要有个注册一个api的key 然后下载一个js代码Google上提供 我给你一个,key自己注册 其中城市,和地址动态添加的 <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(39.917, 116.397), 13); geocoder = new GClientGeocoder(); }}function myClick(address) { // Place a er in the center of the map and open the info window // automatically var er = new GMarker(map.getCenter()); GEvent.addListener(er, "click", function() { //er.openInfoWindowTabsHtml(address); er.openInfoWindowHtml(address); }); map.addOverlay(er); } function showAddress(address) { if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) { //alert("不能解析: " + address); return false; } else { map.setCenter(point, 13); var er = new GMarker(point); map.addOverlay(er); //er.openInfoWindowHtml(address); myClick(address); return true; } } ); } } function getmap() { if (!showAddress('<%=address %>')) showAddress('<%=city %>'); //return false; } </script>
看看这个代码拿来就能用
哦这个是51地图的
google的需要有个注册一个api的key
然后下载一个js代码Google上提供
我给你一个,key自己注册
其中城市,和地址动态添加的 <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(39.917, 116.397), 13);
geocoder = new GClientGeocoder();
}}function myClick(address)
{
// Place a er in the center of the map and open the info window
// automatically
var er = new GMarker(map.getCenter());
GEvent.addListener(er, "click", function()
{
//er.openInfoWindowTabsHtml(address);
er.openInfoWindowHtml(address);
});
map.addOverlay(er);
} function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point)
{
if (!point)
{
//alert("不能解析: " + address);
return false;
}
else
{
map.setCenter(point, 13);
var er = new GMarker(point);
map.addOverlay(er);
//er.openInfoWindowHtml(address);
myClick(address);
return true;
}
}
);
}
}
function getmap()
{
if (!showAddress('<%=address %>'))
showAddress('<%=city %>');
//return false;
}
</script>
http://code.google.com/intl/zh-CN/apis/maps/
http://www.cnblogs.com/zbqy/articles/852703.html
http://www.cnblogs.com/liangqihui/archive/2008/02/15/1069733.html
http://news.csdn.net/n/20081207/121545.html