1

我正在使用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并手动重命名吗?

4

1 回答 1

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);
于 2013-06-18T14:42:24.127 回答