gpt4 book ai didi

geojson - 从 mapbox gl 中的 geojson 获取图标 url

转载 作者:行者123 更新时间:2023-12-04 14:14:37 29 4
gpt4 key购买 nike

我有这个 geojson

{
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[
-75.70439994335175,
4.72285137053331
]
},
"properties":{
"category":"pajaros",
"icon":{
"iconUrl":"http:\/\/tupale.co\/milfs\/images\/secure\/?file=150\/b93a3b673df42a1eb5ca85ffcfa21389.jpg\u002674",
"iconSize":[
60
]
},

"563":"",
"564":"b93a3b673df42a1eb5ca85ffcfa21389.jpg",
"567":"-75.70439994335175 4.72285137053331 18",
"title":"Semillero andino ( hembra )",
"566":"Semillero andino ( hembra )",
"localizacion":"-75.70439994335175 4.72285137053331 18 ",
"description":"Contenido del json",
"control":"024a69ad3b495e5c323402211bc7aa97",
"latLng":[
-75.70439994335175,
4.72285137053331
],
"time":1467590201,
"name":1480263964
}
}
]
}

还有这个功能

        /**
* This is where your '.addLayer()' used to be, instead
* add only the source without styling a layer
*/
map.addSource('places', {
'type': 'geojson',
// 'data': stores
'data': 'http://localhost/tupali/cache/45.json'
});
map.addLayer({
'id': 'points',
'type': 'symbol',
'source': 'places',
'layout': {
// get the icon name from the source's "icon" property
// concatenate the name to get an icon from the style's sprite sheet
'icon-image': ['concat', ['get', 'iconUrl'], '-15'],
// get the title name from the source's "title" property
'text-field': ['get', 'title'],
'text-font': ['Open Sans Semibold', 'Arial Unicode MS Bold'],
'text-offset': [0, 0.6],
'text-anchor': 'top'
}
});

});

如何从 geojson 获取 iconUrl 和图标大小?我尝试“'icon-image': ['concat', ['get', 'icon'], '-15'],”但是得到任何阵列,我不知道如何爆炸。“图片”{“iconUrl”:“http://localhost//tupali/milfs/images/secure/?file=150/e1b0013409d0ed4a67c292999928c295.jpg&74”,“iconSize”:[60]}“无法加载。”

最佳答案

Mapbox-GL-JS 无法通过这种方式通过 URL 加载图像。您需要先使用 map.loadImage()map.addImage() 添加所需的图像。

https://docs.mapbox.com/mapbox-gl-js/api/#map#loadimage

关于geojson - 从 mapbox gl 中的 geojson 获取图标 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61684198/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com