使用jquery选择和本地化传单层名称

时间:2013-06-18 13:25:47

标签: jquery leaflet

我正在使用leafletjs - http://leafletjs.com/

我需要将图层和覆盖文本本地化为用户选择的语言。

传单代码如下:

// create map
map = L.map('map', {
    center: [dlat, dlng],
    zoom: dzoom,
    layers: [osmap, markersgroup, POIgroup, mylayergroup, fencesgroup]
});
var baseLayers = {
    "Normal": osmap,
    "Satellite": satellite
};

var overlays = {
    "All Markers": markersgroup,
    "Online Markers": onlinegroup,
    "Offline Markers": offlinegroup,
    "Live Markers": livegroup
};

如您所见,叠加层名称设置为“所有标记”,“在线标记”等。我需要能够选择这些并更改为法语,西班牙语字符串。

html的呈现方式如下:

<div class="leaflet-control-layers-overlays">
<label>
<input type="checkbox" class="leaflet-control-layers-selector" checked="">
<span> All Markers</span>
</label>
<label>
<input type="checkbox" class="leaflet-control-layers-selector">
<span> Online Markers</span>
</label>
<label>
<input type="checkbox" class="leaflet-control-layers-selector">
<span> Offline Markers</span>
</label>
<label>
<input type="checkbox" class="leaflet-control-layers-selector">
<span> Live Markers</span>
</label>
</div>

我可以在每个span中选择label并手动重命名吗?

1 个答案:

答案 0 :(得分:0)

刚做了这个

$(".leaflet-control-layers-overlays span").eq(0).text(strings[strLang].allMarkers);
$(".leaflet-control-layers-overlays span").eq(1).text(strings[strLang].onlineMarkers);
$(".leaflet-control-layers-overlays span").eq(2).text(strings[strLang].offlineMarkers);
$(".leaflet-control-layers-overlays span").eq(3).text(strings[strLang].liveMarkers);