高德地圖api 標記位置
阿新 • • 發佈:2019-02-01
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <title>點標記的拖拽效果</title> <link rel="stylesheet" type="text/css" href="http://developer.amap.com/Public/css/demo.Default.css" /> <script language="javascript" src="http://webapi.amap.com/maps?v=1.3&key=792e8b96b69121d45328b870ce80c0a7"></script> <script language="javascript"> var mapObj; function mapInit() { mapObj = new AMap.Map("iCenter", { //二維地圖顯示視口 view : new AMap.View2D({ center : new AMap.LngLat(11322509.0 / 100000, 3065219.0 / 100000),//地圖中心點 zoom : 12 //地圖顯示的縮放級別 }) }); var marker = new AMap.Marker({ position : mapObj.getCenter(), draggable : true, //點標記可拖拽 cursor : 'move', //滑鼠懸停點標記時的滑鼠樣式 raiseOnDrag : true //滑鼠拖拽點標記時開啟點標記離開地圖的效果 }); marker.setMap(mapObj); } </script> </head> <body onLoad="mapInit()"> <div id="iCenter" style="width: 500px; height: 600px"></div> <p>滑鼠拖拽點標記試試</p> </body> </html>