Mapbox - Custom marker icons from GeoJson properties

人盡茶涼 提交于 2019-12-24 03:29:53

问题


I'm rendering markers from a an array of GeoJson objects. I'd like to use custom icons for the markers but am not able to determine the correct syntax. Below is a portion of the code I'm using to render the geojson:

asGeoJson: ->
  type: "Feature"
  properties:
    title: @get("list_no")
    price: @get("price")
    address: @get("address")
    url: @url()
    id: @get("id")
    icon:
      iconUrl: "/images/map_icon.png"
      iconSize: [50, 50]
      iconAnchor: [25,25]
      popupAnchor: [0, -25]
      className: "marker"

The GeoJson is rendered via something like L.mapbox.featureLayer(geoJson()). I'm not able to find a concise answer in the mapbox docs for how to specify a custom marker inside GeoJson. Is it even possible to customize the icon via setting icon properties inside GeoJson?

来源:https://stackoverflow.com/questions/23234428/mapbox-custom-marker-icons-from-geojson-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!