{"id":326,"date":"2021-12-24T10:02:46","date_gmt":"2021-12-24T02:02:46","guid":{"rendered":"http:\/\/gjweb.top\/?p=326"},"modified":"2021-12-24T10:02:46","modified_gmt":"2021-12-24T02:02:46","slug":"%e9%ab%98%e5%be%b7%e5%9c%b0%e5%9b%be%e8%81%9a%e5%90%88%e7%82%b9%e7%82%b9%e5%87%bb%e4%ba%8b%e4%bb%b6-2","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=326","title":{"rendered":"\u9ad8\u5fb7\u5730\u56fe\u805a\u5408\u70b9\u70b9\u51fb\u4e8b\u4ef6"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>map.plugin(&#91;\"AMap.MarkerClusterer\"], function() {<br> &nbsp; &nbsp; &nbsp; &nbsp;cluster = new AMap.MarkerClusterer(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map, \/\/ \u5730\u56fe\u5b9e\u4f8b<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;markers, \/\/ \u6d77\u91cf\u70b9\u7ec4\u6210\u7684\u6570\u7ec4<br> &nbsp; &nbsp; &nbsp; &nbsp;  {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;styles: styles<br> &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp;  );<br> &nbsp; &nbsp; &nbsp; &nbsp;cluster.on(\"click\",({cluster,lnglat,target,marker})=&gt;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lnglatData = lnglat<br> &nbsp; &nbsp; &nbsp;  })<br>});<\/code><\/pre>\n\n\n\n<p>\u5b8c\u6574\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>loadmap(map, data, icon) {<br> &nbsp; &nbsp; &nbsp;let _self = this;<br> &nbsp; &nbsp; &nbsp;var map = new AMap.Map(map, {<br> &nbsp; &nbsp; &nbsp; &nbsp;zoom: 5,<br> &nbsp; &nbsp; &nbsp; &nbsp;center: &#91;106.143065, 33.058826],<br> &nbsp; &nbsp; &nbsp; &nbsp;resizeEnable: true<br> &nbsp; &nbsp;  });<br> &nbsp; &nbsp; &nbsp;var that = this;<br> &nbsp; &nbsp; &nbsp;map.setMapStyle(\"amap:\/\/styles\/darkblue\");<br> &nbsp; &nbsp; &nbsp;map.on(\"complete\", function() {<br> &nbsp; &nbsp; &nbsp; &nbsp;that.isshow = false;<br> &nbsp; &nbsp;  });<br> &nbsp; &nbsp; &nbsp;var cluster;<br> &nbsp; &nbsp; &nbsp;var markers = &#91;];<br> &nbsp; &nbsp; &nbsp;for (var i = 0; i &lt; data.length; i++) {<br> &nbsp; &nbsp; &nbsp; &nbsp;var marker = new AMap.Marker({<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;icon: icon,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;position: &#91;data&#91;i].lng, data&#91;i].lat],<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ title: data&#91;i].name<br> &nbsp; &nbsp; &nbsp;  });<br> &nbsp; &nbsp; &nbsp; &nbsp;marker.on(\"click\",({lnglat})=&gt;{<br> &nbsp; &nbsp; &nbsp; &nbsp;    console.log(\"\u70b9\u51fb\u5355\u4e2a\u70b9\")<br> &nbsp; &nbsp; &nbsp;  })<br> &nbsp; &nbsp; &nbsp; &nbsp;markers.push(marker);<br> &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp;var styles = &#91;<br> &nbsp; &nbsp; &nbsp;  {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url: icon,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;size: new AMap.Size(40, 84),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;offset: new AMap.Pixel(-40, -84),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;textColor: \"#fff\",<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp;  ];<br> &nbsp; &nbsp; &nbsp;\/\/ \u76d1\u542c\u5730\u56fe\u7f29\u653e\u7b49\u7ea7\u548c\u805a\u5408\u70b9\u6570\u636e<br> &nbsp; &nbsp; &nbsp;var lnglatData = {}<br> &nbsp; &nbsp; &nbsp;var getZoom = \"\"<br> &nbsp; &nbsp; &nbsp;map.plugin(&#91;\"AMap.MarkerClusterer\"], function() {<br> &nbsp; &nbsp; &nbsp; &nbsp;cluster = new AMap.MarkerClusterer(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map, \/\/ \u5730\u56fe\u5b9e\u4f8b<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;markers, \/\/ \u6d77\u91cf\u70b9\u7ec4\u6210\u7684\u6570\u7ec4<br> &nbsp; &nbsp; &nbsp; &nbsp;  {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;styles: styles<br> &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp;  );<br> &nbsp; &nbsp; &nbsp; &nbsp;cluster.on(\"click\",({cluster,lnglat,target,marker})=&gt;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(\"\u70b9\u51fb\u805a\u5408\")<br> &nbsp; &nbsp; &nbsp;  })<br> &nbsp; &nbsp;  });<br>},<br>loadmap(\u5bb9\u5668ID, \u6570\u636e\u6e90, \u56fe\u6807);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b8c\u6574\u4ee3\u7801<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-326","post","type-post","status-publish","format-standard","hentry","category-39"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}