日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

高德开放平台实现区域地图+云图标记

發(fā)布時(shí)間:2023/12/14 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 高德开放平台实现区域地图+云图标记 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在項(xiàng)目中需要使用類似GIS效果的地圖,考慮到高德開放平臺(tái)關(guān)于云圖的便利性,便利用官網(wǎng)和網(wǎng)上的例子,進(jìn)行了初步實(shí)現(xiàn)。

1.帶3D效果:

2.代碼:

<!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><script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.14&key=760d16c25fa8ee3c547b693a6c414821&plugin=Map3D,AMap.DistrictSearch"></script><style>html,body,#container {margin: 0;height: 100%;}</style> </head> <body><div id="container"></div><script>var mask = [];var map = new AMap.Map('container', {mask: mask,resizeEnable: true,zoom: 12,viewMode: '3D',center: [121.124178, 31.150681],mapStyle: 'amap://styles/5a2dbb143362de08809a8aebe25ca455',//layers: [// new AMap.TileLayer.RoadNet({// zIndex: 20// })]//,// new AMap.TileLayer({// zIndex: 6,// opacity: 1,//getTileUrl: 'https://t{1,2,3,4}.tianditu.gov.cn/DataServer?T=ter_w&x=[x]&y=[y]&l=[z]'//getTileUrl: 'https://t{s}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=5ecfe4e0cecdafec9a858e37c261084c'//})]});map.plugin('AMap.CloudDataLayer', function () {var layerOptions = {query: { keywords: '' },clickable: true};var cloudDataLayer = new AMap.CloudDataLayer('5cbec0902376c10e3dec70d6', layerOptions); //實(shí)例化云圖層類cloudDataLayer.setMap(map); //疊加云圖層到地圖});new AMap.DistrictSearch({extensions: 'all',subdistrict: 0}).search('青浦區(qū)', function (status, result) {// 外多邊形坐標(biāo)數(shù)組和內(nèi)多邊形坐標(biāo)數(shù)組var 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),];var holes = result.districtList[0].boundariesvar pathArray = [outer];for (var i = 0; i < holes.length; i += 1) {mask.push([holes[i]])}pathArray.push.apply(pathArray, holes)var polygon = new AMap.Polygon({pathL: pathArray,strokeColor: '#00eeff',strokeWeight: 1,fillColor: '#71B3ff',fillOpacity: 0.5});polygon.setPath(pathArray);map.add(polygon);var bounds = map.getBounds(); // 獲取顯示范圍map.setLimitBounds(bounds); // 限制地圖顯示范圍var object3Dlayer = new AMap.Object3DLayer({ zIndex: 1 });map.add(object3Dlayer)var height = -8000;var color = '#0088ffcc';//rgbavar wall = new AMap.Object3D.Wall({path: holes,height: height,color: color});wall.transparent = trueobject3Dlayer.add(wall)});</script></body> </html>

3.不帶3D效果。帶彈窗

4.代碼:

<!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><script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.14&key=760d16c25fa8ee3c547b693a6c414821&plugin=AMap.DistrictSearch,Map3D"></script><script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script><style>html,body,#container {margin: 0;height: 100%;}</style> </head> <body><div id="container"></div><script>var map = new AMap.Map('container', {resizeEnable: true,zoom: 12,viewMode: '3D',center: [121.124178, 31.150681],mapStyle: 'amap://styles/5a2dbb143362de08809a8aebe25ca455',//layers: [// new AMap.TileLayer.RoadNet({// zIndex: 20// })]//,// new AMap.TileLayer({// zIndex: 6,// opacity: 1,//getTileUrl: 'https://t{1,2,3,4}.tianditu.gov.cn/DataServer?T=ter_w&x=[x]&y=[y]&l=[z]'//getTileUrl: 'https://t{s}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=5ecfe4e0cecdafec9a858e37c261084c'//})]});new AMap.DistrictSearch({extensions: 'all',subdistrict: 0}).search('青浦區(qū)', function (status, result) {// 外多邊形坐標(biāo)數(shù)組和內(nèi)多邊形坐標(biāo)數(shù)組var 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),];var holes = result.districtList[0].boundariesvar pathArray = [outer];pathArray.push.apply(pathArray, holes)var polygon = new AMap.Polygon({pathL: pathArray,strokeColor: '#00eeff',strokeWeight: 1,fillColor: '#71B3ff',fillOpacity: 0.5});polygon.setPath(pathArray);map.add(polygon);var bounds = map.getBounds(); // 獲取顯示范圍map.setLimitBounds(bounds); // 限制地圖顯示范圍});map.plugin('AMap.CloudDataLayer', function () {var layerOptions = {query: { keywords: '' },clickable: true};var cloudDataLayer = new AMap.CloudDataLayer('5cbec0902376c10e3dec70d6', layerOptions); //實(shí)例化云圖層類cloudDataLayer.setMap(map); //疊加云圖層到地圖AMap.event.addListener(cloudDataLayer, 'click', function (result) {var clouddata = result.data;var photo = [];if (clouddata._image[0]) {//如果有上傳的圖片photo = ['<img width=240 height=100 src="' + clouddata._image[0]._preurl + '"><br>'];}var infoWindow = new AMap.InfoWindow({content: "<font class='title'>" + clouddata._name + "</font><hr/>" + photo.join("") + "地址:" + clouddata._address + "<br />" + "聯(lián)系電話:" + clouddata.telephone + "<br />" + "經(jīng)緯度:" + clouddata._location,size: new AMap.Size(0, 0),autoMove: true,offset: new AMap.Pixel(0, -25)});infoWindow.open(map, clouddata._location);console.log(clouddata._name);});});</script></body> </html>

不足:無法實(shí)現(xiàn)在云圖中添加文本標(biāo)簽,無法標(biāo)記這些點(diǎn)的名稱,而是需要設(shè)置彈窗點(diǎn)擊事件。要是有完成這部分的煩請(qǐng)留言,不勝感激。

總結(jié)

以上是生活随笔為你收集整理的高德开放平台实现区域地图+云图标记的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。