首页 > 代码库 > 高德地图-添加自定义图标
高德地图-添加自定义图标
- <!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://www.mamicode.com/"http://cache.amap.com/lbs/static/main1119.css"/>
- <script type="text/javascript" src=http://www.mamicode.com/"../js/jquery-1.12.3.js" ></script>
- <script src=http://www.mamicode.com/"http://webapi.amap.com/maps?v=1.3&key=c2eb520334ddc5ab2bb70a3afe6a58cc"></script>
- <script type="text/javascript" src=http://www.mamicode.com/"http://cache.amap.com/lbs/static/addToolbar.js"></script>
- <style>
- body,html{
- width: 99%;
- height: 99%;
- font-family: "微软雅黑";
- font-size: 12px;
- font-size-adjust: initial;
- }
- #keyMap{
- width: 100%;
- height: 100%;
- font-family: "arial rounded mt bold";
- font-size: -webkit-xxx-large;
- }
- </style>
- </head>
- <body>
- <div id="keyMap"></div>
- <div class="button-group">
- <input type="button" class="button" id="addTag" value=http://www.mamicode.com/"添加点标记"/>
- </div>
- <script>
- var marker;
- var map = new AMap.Map("keyMap",{
- resizeEnable: true,
- center: [114.297199,30.573714],
- zoom: 13
- });
- AMap.event.addDomListener(document.getElementById(‘addTag‘), ‘click‘, function() {
- addTags();
- }, false);
- function addTags()
- {
- if(marker)
- {
- return;
- }
- marker = new AMap.Marker({
- icon:"../img/ooopic_1464187636.png", //路径
-
size: new AMap.Size(40, 50),//图片大小
- position:[114.297199,30.573714] //图片出现的经纬度
- });
- marker.setMap(map);
- }
- </script>
- </body>
- </html>
高德地图-添加自定义图标
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。