使用Google Maps JavaScript API V3
最近在做一个ASP.NET MVC的项目,要用到Google Maps JavaScript API V3,就尝试了一下,废话就不说了,里面有注释
代码如下:
<!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"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=zh-CN"></script> <script type="text/javascript"> function init() { var map = new google.maps.Map(document.getElementById("map"), { zoom: 15, //放大比例 center: new google.maps.LatLng(31.3, 120.6), //经纬度 mapTypeId: google.maps.MapTypeId.ROADMAP, //地图类型ROADMAP、SATELLITE、HYBRID panControl: false, //方向盘 scaleControl: false, //比例尺 mapTypeControl: false, //可以选的地图类型,下面是配置 //mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, streetViewControl:false,//街头小人 zoomControl: true, //放大按钮,下面是配置 zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL//LARGE //position: google.maps.ControlPosition.LEFT_CENTER } }); var marker = new google.maps.Marker({ map: map, position: map.getCenter() });//显示标记 //var infowindow = new google.maps.InfoWindow();//实例化InfoWindow() //infowindow.setContent('<b>sssss</b>');//显示的信息 //google.maps.event.addListener(marker, 'click', function () { //infowindow.open(map, marker); //});//添加Listener //google.maps.event.addDomListener(document.getElementById('map'), 'click', function () { alert("dd") }); } </script> </head> <body onload="init()"> <div id="map" style="width:240px;height:240px"></div> </body> </html>