在这个 Leaflet 应用程序中,我显示了丹麦所有可用的巴士站。
http://drivetime.mapicture.dk/stops
奇怪的是,如果您缩小到最后 4 个缩放级别之一,带有这些巴士站的图层就会消失。当您再次缩小时,它们会重新出现。
公交车站是通过向我们的地理服务器发出的 WMS 请求检索到的单层。整个 javascript 代码实际上非常简单,所以我很难找出导致这种行为的原因。
function CurrentStopsMap(mapNode, zoomSettings) {
var self = this;
self.mapNode = mapNode;
self.zoomSettings = zoomSettings;
self.mapquest = new L.TileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: "©<a href='http://openstreetmap.org/' target='_blank'>OpenStreetMap</a> contributors, Tiles Courtesy of <a href='http://open.mapquest.com' target='_blank'>MapQuest</a>",
subdomains: ['1', '2', '3', '4']
});
self.regions = new L.TileLayer.WMS("http://backend.mapicture.dk:8080/geoserver/mapicture/wms", {
layers: 'mapicture:region',
format: 'image/png',
styles: 'regions',
transparent: false
});
self.stops = new L.TileLayer.WMS("http://backend.mapicture.dk:8080/geoserver/mapicture/wms", {
layers: 'mapicture:stops',
format: 'image/png',
transparent: true
});
self.map = new L.Map(mapNode, {
center: new L.LatLng(zoomSettings.lat, zoomSettings.lon),
zoom: zoomSettings.level,
layers: [self.mapquest, self.stops],
zoomControl: true
});
L.control.layers({
"Kort": self.mapquest,
"Områder": self.regions
}, {
"Stoppesteder": self.stops
}).addTo(self.map);
}
var zoom = {
lat: 56.24,
lon: 10.68,
level: 7
};
var map = new CurrentStopsMap('map', zoom)