我正在使用GeoJSON作为Google地图的数据源.我正在使用API的v3来创建数据层,如下所示:
我的GeoJSON数据的来源如下:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "icon": "/static/images/icons/map-marker-do.png", "coordinates": [ -0.53743, 53.23437 ] }, "properties": { "name": "Cathedral", "description": "One of Europe’s finest Gothic buildings, once the tallest building in the world that dominates Lincoln's skyline.", "icon": "/static/images/icons/map-marker-do.png" } } ] }
我正在试图做的是使地图来自于JSON的"图标"属性上标记的图标,但无法弄清楚如何获取数据更改默认标记.有人可以提供任何建议吗?谢谢.
使用样式功能(样式功能使您可以根据特定功能应用样式)
map.data.setStyle(function(feature) { return {icon:feature.getProperty('icon')}; });