高德地圖 自定義點標記 圖示大小
阿新 • • 發佈:2019-01-27
<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"> <title>自定義點標記圖示大小</title> <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/> <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.5&key=申請的key"></script> <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script> </head> <body> <div id="container"></div> <script type="text/javascript"> //初始化地圖物件,載入地圖 var map = new AMap.Map("container", { resizeEnable: true, zoom:17 }); //新增點標記,並使用自己的icon new AMap.Marker({ map: map, position: [114.597599,37.605084], icon: new AMap.Icon({ image: "marker1.png", size: new AMap.Size(52, 52, //圖示大小 imageSize: new AMap.Size(26,26) }) }); //新增點標記,並使用自己的icon new AMap.Marker({ map: map, position: [114.597181,37.605161], icon: new AMap.Icon({ image: "marker2.png", size: new AMap.Size(52, 52), //圖示大小 imageSize: new AMap.Size(26,26) }) }); </script> </body> </html>