[英]Mapbox marker with multiple titles
At some locations (coordinates) multiple points exist and I want the titles to be combined in the tooltip. 在某些位置(坐标)存在多个点,并且我希望标题在工具提示中组合。
Here's the jbuilder file 这是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
At some coordinates several items may exist. 在某些坐标处,可能存在多个项目。 Only one shows up.
只有一个出现。 I tried MarkerClusterGroup and all the items show up, but would rather have the titles just stacked in one tooltip.
我尝试了MarkerClusterGroup并显示了所有项目,但宁愿标题只是堆积在一个工具提示中。 Any hints on how to go about this?
有关如何进行此操作的任何提示? Thank you
谢谢
The js file 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());
});
}
Not a complete answer, but I think I can test in jbuilder and build up the Title. 这不是一个完整的答案,但是我想我可以在jbuilder中进行测试并建立Title。
Started to think this through and it wouldn't be straightforward. 开始考虑到这一点,这并不容易。 Might require database to be modified which if it works out is OK.
可能需要修改数据库,如果解决可以。
Easier if Mapbox/Leaflet could handle it. 如果Mapbox / Leaflet可以处理它,则更容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.