簡體   English   中英

具有多個標題的Mapbox標記

[英]Mapbox marker with multiple titles

在某些位置(坐標)存在多個點,並且我希望標題在工具提示中組合。

這是jbuilder文件

json.type "FeatureCollection"
json.features @years do |year|
  json.type "Feature"
  json.properties do
    if (year.resto)
      json.set! "marker-color", "#9932CC"
      json.set! "marker-symbol", "restaurant"
    else
      json.set! "marker-color", "#5cb85c"
      json.set! "marker-symbol", "lodging"
    end

    json.set! "marker-size", "small"
    json.title "#{year.person.given_name} #{year.person.last_name} was a #{year.title} at #{year.location.address} on #{year.year_date}" 
  end
  if (year.location.longitude) 
    json.geometry do
      json.type "Point"
      json.coordinates [year.location.longitude, year.location.latitude]
    end
  end
end

在某些坐標處,可能存在多個項目。 只有一個出現。 我嘗試了MarkerClusterGroup並顯示了所有項目,但寧願標題只是堆積在一個工具提示中。 有關如何進行此操作的任何提示? 謝謝

js文件

function makeMap() {
  L.mapbox.accessToken = $('body').data('mapboxToken');
  var map = L.mapbox.map('map', 'mapbox.streets')
             .setView([34.040951, -118.258579], 13);

  var featureLayer = L.mapbox.featureLayer()
                    .loadURL('map/map_data.geojson')
                    .addTo(map);

  featureLayer.on('ready', function(e) {
    map.fitBounds(featureLayer.getBounds());
  });
}

這不是一個完整的答案,但是我想我可以在jbuilder中進行測試並建立Title。

開始考慮到這一點,這並不容易。 可能需要修改數據庫,如果解決可以。

如果Mapbox / Leaflet可以處理它,則更容易。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM