forked from MTSR/mapserver
label overlay
This commit is contained in:
parent
d710159bf8
commit
34ebe37c66
@ -34,6 +34,7 @@
|
|||||||
<script src="js/overlays/AbstractGeoJsonOverlay.js"></script>
|
<script src="js/overlays/AbstractGeoJsonOverlay.js"></script>
|
||||||
<script src="js/overlays/TravelnetOverlay.js"></script>
|
<script src="js/overlays/TravelnetOverlay.js"></script>
|
||||||
<script src="js/overlays/PoiOverlay.js"></script>
|
<script src="js/overlays/PoiOverlay.js"></script>
|
||||||
|
<script src="js/overlays/LabelOverlay.js"></script>
|
||||||
<script src="js/overlays/PlayerOverlay.js"></script>
|
<script src="js/overlays/PlayerOverlay.js"></script>
|
||||||
<script src="js/overlays/ProtectorOverlay.js"></script>
|
<script src="js/overlays/ProtectorOverlay.js"></script>
|
||||||
<script src="js/overlays/BonesOverlay.js"></script>
|
<script src="js/overlays/BonesOverlay.js"></script>
|
||||||
|
@ -31,6 +31,7 @@ api.getConfig().then(function(cfg){
|
|||||||
|
|
||||||
overlays["Player"] = new PlayerOverlay(wsChannel, layerMgr);
|
overlays["Player"] = new PlayerOverlay(wsChannel, layerMgr);
|
||||||
overlays["POI"] = new PoiOverlay(wsChannel, layerMgr);
|
overlays["POI"] = new PoiOverlay(wsChannel, layerMgr);
|
||||||
|
overlays["Labels"] = new LabelOverlay(wsChannel, layerMgr);
|
||||||
overlays["Travelnet"] = new TravelnetOverlay(wsChannel, layerMgr);
|
overlays["Travelnet"] = new TravelnetOverlay(wsChannel, layerMgr);
|
||||||
overlays["Bones"] = new BonesOverlay(wsChannel, layerMgr);
|
overlays["Bones"] = new BonesOverlay(wsChannel, layerMgr);
|
||||||
overlays["Digilines LCD"] = new LcdOverlay(wsChannel, layerMgr);
|
overlays["Digilines LCD"] = new LcdOverlay(wsChannel, layerMgr);
|
||||||
@ -43,6 +44,7 @@ api.getConfig().then(function(cfg){
|
|||||||
//Default enabled overlays
|
//Default enabled overlays
|
||||||
map.addLayer(overlays["Player"]);
|
map.addLayer(overlays["Player"]);
|
||||||
map.addLayer(overlays["POI"]);
|
map.addLayer(overlays["POI"]);
|
||||||
|
map.addLayer(overlays["Labels"]);
|
||||||
|
|
||||||
L.control.layers(layers, overlays).addTo(map);
|
L.control.layers(layers, overlays).addTo(map);
|
||||||
|
|
||||||
|
@ -23,7 +23,11 @@ var AbstractIconOverlay = L.LayerGroup.extend({
|
|||||||
|
|
||||||
if (marker) {
|
if (marker) {
|
||||||
//marker exists
|
//marker exists
|
||||||
marker.setPopupContent(self.createPopup(obj));
|
var popup = self.createPopup(obj);
|
||||||
|
if (popup)
|
||||||
|
marker.setPopupContent(popup);
|
||||||
|
|
||||||
|
marker.setIcon(this.getIcon(obj));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -81,12 +85,21 @@ var AbstractIconOverlay = L.LayerGroup.extend({
|
|||||||
|
|
||||||
if (marker) {
|
if (marker) {
|
||||||
//marker exists
|
//marker exists
|
||||||
marker.setPopupContent(self.createPopup(obj));
|
|
||||||
|
//set popup, if changed
|
||||||
|
var popup = self.createPopup(obj);
|
||||||
|
if (popup)
|
||||||
|
marker.setPopupContent(popup);
|
||||||
|
|
||||||
|
//redraw icon, if changed
|
||||||
|
marker.setIcon(self.getIcon(obj));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//marker does not exist
|
//marker does not exist
|
||||||
marker = L.marker([obj.z, obj.x], {icon: self.getIcon(obj)});
|
marker = L.marker([obj.z, obj.x], {icon: self.getIcon(obj)});
|
||||||
marker.bindPopup(self.createPopup(obj));
|
var popup = self.createPopup(obj);
|
||||||
|
if (popup)
|
||||||
|
marker.bindPopup(popup);
|
||||||
marker.addTo(self);
|
marker.addTo(self);
|
||||||
|
|
||||||
self.currentObjects[hash] = marker;
|
self.currentObjects[hash] = marker;
|
||||||
|
15
server/static/js/overlays/LabelOverlay.js
Normal file
15
server/static/js/overlays/LabelOverlay.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var LabelOverlay = AbstractIconOverlay.extend({
|
||||||
|
initialize: function(wsChannel, layerMgr) {
|
||||||
|
AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "digiterm");
|
||||||
|
},
|
||||||
|
|
||||||
|
getIcon: function(lbl){
|
||||||
|
return L.divIcon({html: lbl.attributes.text});
|
||||||
|
},
|
||||||
|
|
||||||
|
createPopup: function(lbl){
|
||||||
|
return "<pre>" + lbl.attributes.text + "</pre>";
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user