日期:2014-05-16 浏览次数:20385 次
<html> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://ditu.google.com/maps?file=api&v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=zh-CN"></script> <script type="text/javascript"> var map; //声明一个GMap2全局变量 function load() { //检查浏览器的兼容性. if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); //加载地图 map.addControl(new GLargeMapControl()); //增加全功能控件 map.addControl(new GMapTypeControl()); //设置地图类型 map.enableScrollWheelZoom(); //设置地图支持滚轮 map.setCenter(new GLatLng(39.990168, 116.295304), 10); //设置地图的中心坐标 map.enableDoubleClickZoom(); //开启双击google map会自动放大. map.enableScrollWheelZoom(); //开启滚动鼠标自动放大和缩小. //============================================================== var icon = new GIcon(G_DEFAULT_ICON); var point = new GPoint(116.429114, 39.934322); var html = '<div ><font color="blue">HelloWorld!</font></div>'; var marker = createMarker(icon, point, html); map.addOverlay(marker); //============================================================== } } function createMarker(baseIcon, point, html) { var icon = new GIcon(baseIcon); var marker = new GMarker(point, icon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; } </script> </head> <body onload="load()" onunload=" GUnload();"> <table border="2" id="table1" bordercolor="#FF0000"> <tr> <td> <!-- 地图画板 --> <div id="map" style=" text-align:center; width:800px; height:480px"></div> </td> </tr> </table> </body> </html>
------解决方案--------------------
LZ想用google的哪种地图呢?
先给你一份V2版的简单的地图吧。自己把红色部分替换成自己的key就可以了!!
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Control Initialization</title> <script src="//maps.google.com/maps?file=api&v=2&key=[color=#FF0000]ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA[/color]" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas"), { size: new GSize(640,320) } ); map.setCenter(new GLatLng(42.366662,-71.106262), 11); var customUI = map.getDefaultUI(); // Remove MapType.G_HYBRID_MAP customUI.maptypes.hybrid = false; map.setUI(customUI); } } //]]> </script> </head> <body onload="initialize()" onunload="GUnload()"> <div id="map_canvas" style="width: 640px; height: 320px"&