我正在寻找一种方法,可以让我像Mapbox JS
这样为我的地图创建一个简单的自定义标记。
深入浏览了网络,似乎没有明显或直接的方法来实现这一目标。我猜这是一个被错过的功能。
尝试了几次Mapbox Studio
,但仍然没有运气,因为很难理解如何上传自定义 SVG 并能够引用它们。
举个例子,我创建了一个自定义地图,Mapbox Studio
据我所知,没有可以使用的图标。确实尝试寻找一种称为精灵表的东西,但是由于我从未使用过这种方法,所以我不知道该怎么做。
我想这很重要,不仅对我来说,而且对很多刚开始学习新东西的人来说,就像Mapbox GL JS
附上一个很好的指南一样。
所以这是我的一些关于创建一些自定义标记的代码
markers = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"marker-symbol": "golf",
"type": "journey-step",
"previous": "0",
"current": "1",
"next": "2"
},
"geometry": {
"type": "Point",
"coordinates": [-155.98114013671872,
19.70207180765683
]
}
}, {
"type": "Feature",
"properties": {
"marker-color": "#7f201e",
"marker-size": "medium",
"marker-symbol": "music",
"type": "journey-step",
"previous": "1",
"current": "2",
"next": "3"
},
"geometry": {
"type": "Point",
"coordinates": [-155.67352294921875,
19.01278705937288
]
}
}, {
"type": "Feature",
"properties": {
"icon-symbol": "Four",
"type": "journey-step",
"previous": "2",
"current": "3",
"next": "4"
},
"geometry": {
"type": "Point",
"coordinates": [-155.2423095703125,
19.42644883261674
]
}
}, {
"type": "Feature",
"properties": {
"marker-color": "#7f201e",
"marker-size": "medium",
"marker-symbol": "theatre",
"type": "journey-step",
"previous": "3",
"current": "4",
"next": "5"
},
"geometry": {
"type": "Point",
"coordinates": [-155.10223388671875,
19.698193071745962
]
}
}, {
"type": "Feature",
"properties": {
"marker-color": "#7f201e",
"marker-size": "medium",
"marker-symbol": "alcohol-shop-12",
"type": "journey-step",
"previous": "4",
"current": "5",
"next": "6"
},
"geometry": {
"type": "Point",
"coordinates": [-155.38787841796872,
20.04303061200023
]
}
}, {
"type": "Feature",
"properties": {
"marker-color": "#7f201e",
"marker-size": "medium",
"marker-symbol": "theatre",
"type": "journey-step",
"previous": "5",
"current": "6",
"next": "7"
},
"geometry": {
"type": "Point",
"coordinates": [-155.8575439453125,
20.229986070955245
]
}
}, {
"type": "Feature",
"properties": {
"marker-color": "#7f201e",
"marker-size": "medium",
"marker-symbol": "theatre",
"type": "journey-step",
"previous": "6",
"current": "7",
"next": "8"
},
"geometry": {
"type": "Point",
"coordinates": [-155.89599609375,
19.46400263520258
]
}
}]
};
map.addSource("markers", {
"type": "geojson",
"data": markers
});
map.addLayer({
"id": markers,
"type": "symbol",
"source": "markers"
});
您可以猜到,我的地图没有显示任何图标。
任何人都可以提出一种良好且易于理解的方法来实现对地图库至关重要的事情吗?