我想根据最近的草皮更改地图点击时的图标大小。我如何做到这一点?nearestBuilding.properties['icon-size'] = 0.2;不起作用。
var retail = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {
title: 'TEST',
description: 'TEST'
},
geometry: {
type: 'Point',
coordinates: [121.051779, 14.550224]
}
},
{
type: 'Feature',
properties: {
title: 'TEST',
description: 'TEST'
},
geometry: {
type: 'Point',
coordinates: [121.04568958282472, 14.552170837008527]
}
}
]
};
map.on('load', function() {
map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Wiki_Loves_Earth_map_marker.svg/600px-Wiki_Loves_Earth_map_marker.svg.png', function(error, image) {
if (error) throw error;
map.addImage('marker', image);
map.addLayer({
id: 'retail',
type: 'symbol',
source: {
type: 'geojson',
data: retail
},
layout: { …Run Code Online (Sandbox Code Playgroud) 当我在地图框上使用草皮时,特别是以下行,它会产生错误var nearestBuilding = turf.nearest(currentLocation, geoJson);。我使用mapbox-gl和草皮来获取最近的建筑物。当我手动输入数据而无需object.push()但我需要数据库中的信息时,它会起作用。
var object = [];
for (var x = 0; x < json.length; x++) {
var
image = json[x].image == '' ? '' : "<div style='text-align:center;'><img src='" + json[x].image + "' width='100' height='75' /></div>",
number = json[x].contact == '' ? '' : "<br/>" + json[x].contact,
details = json[x].details == '' ? '' : '<br/>' + '<a href="{{ url('restaurants-and - cafe') }}/' + json[x].details + '">More Details</a>';
object.push({
type: 'Feature',
properties: {
title: …Run Code Online (Sandbox Code Playgroud)