123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <!DOCTYPE html>
- <html>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <meta name="viewport" content="width=device-width,initial-scale=1.0" />
- <title>荟萃楼珠宝黑龙江省</title>
- <script>
- window._AMapSecurityConfig = {
- securityJsCode: '3526b49c1c46354a5f0676002636f360',
- };
- </script>
- <script src="https://webapi.amap.com/loader.js"></script>
- <script type="text/javascript">
- var _this = this;
- let center = [126.661998, 48.742253];
- let zoom = 6.5;
-
- AMapLoader.load({
- key: '94943af79a8a349d045c2b8645cc9db4',
- version: '2.0',
- plugins: ['AMap.PlaceSearch'],
- })
- .then((AMap) => {
- var map = new AMap.Map('container', {
- center,
- zoom,
- mapStyle: 'amap://styles/88ab842bd66e2dcb61aff7f507779c45',
- });
-
- AMap.plugin('AMap.DistrictSearch', function () {
- new AMap.DistrictSearch({
- extensions: 'all',
- subdistrict: 1,
- }).search('黑龙江', function (status, result) {
-
-
- let cityList = result.districtList[0].districtList;
- let outer = [new AMap.LngLat(-360, 90, true), new AMap.LngLat(-360, -90, true), new AMap.LngLat(360, -90, true), new AMap.LngLat(360, 90, true)];
- let holes = result.districtList[0].boundaries;
- let pathArray = [outer];
- pathArray.push.apply(pathArray, holes);
- let polygon = new AMap.Polygon({
- pathL: pathArray,
- strokeColor: 'red',
- strokeWeight: 3,
- fillColor: '#112473',
- fillOpacity: 1,
- });
- polygon.setPath(pathArray);
- map.add(polygon);
- for (let i = 0; i < cityList.length; i++) {
- const { name } = cityList[i];
- _this.setBorder(map, name, i);
- }
- });
- });
-
- _this.findPoint(map);
- })
- .catch((e) => {
- console.error(e);
- });
-
- let colors = [
- '#70F2FF',
- '#7F1CAD',
- '#F1D4E8',
- '#9D2932',
- '#54004E',
- '#00FF00',
- '#177CB0',
- '#1E90FF',
- '#000080',
- '#00FFFF',
- '#3CB371',
- '#CC99FF',
- '#FF6600',
- '#ED5736',
- '#494166',
- '#D9B612',
- '#A98175',
- '#EFDEB0',
- ];
-
- function setBorder(map, cityName, i) {
- let color = colors[i];
- AMap.plugin('AMap.DistrictSearch', function async() {
- new AMap.DistrictSearch({
-
- extensions: 'all',
- subdistrict: 0,
- }).search(cityName, function (status, result) {
-
- let holes = result.districtList.map((i) => i.boundaries);
- holes = holes[0];
-
- let lengthArr = holes.map((i) => i.length);
- let num = lengthArr.reduce((n1, n2) => (n1 > n2 ? n1 : n2));
- let index = lengthArr.findIndex((i) => i === num);
- let pathArray = holes[index];
-
- new AMap.Polygon({
- map: map,
- path: pathArray,
- strokeWeight: 1,
- strokeColor: 'red',
- fillOpacity: 0.3,
- fillColor: color,
- });
- });
- });
- }
-
- function addMarkers(map) {
- if (!map) return;
- }
- let marks = [];
-
- function findPoint(map, pageIndex = 1) {
-
- var placeSearch = new AMap.PlaceSearch({
-
- city: '黑龙江',
- pageSize: 100,
- pageIndex,
- map,
- autoFitView: false,
- });
- placeSearch.search('荟萃楼珠宝', function (status, result) {
-
- let poiList = result.poiList;
- let pois = poiList.pois;
- marks.push(...pois);
-
- let total = poiList.count;
- if (total > marks.length) _this.findPoint(map, pageIndex + 1);
- });
- }
- </script>
- <style>
- body {
- height: 100%;
- width: 100%;
- color: #333;
- background: #e8e8e8;
- font: 14px 'Microsoft YaHei', arial, helvetica, clean, sans-serif;
- overflow: hidden !important;
- -webkit-text-size-adjust: none;
- margin: 0 auto;
- }
- #container {
- height: 100vh;
- width: 100wh;
- }
- </style>
- <body>
- <div id="container"></div>
- </body>
- </html>
|