1
0
forked from MTSR/mapserver

partial working overlay

This commit is contained in:
Thomas Rudin 2019-02-05 21:17:14 +01:00
parent 041131dee4
commit a0872a82f7
6 changed files with 17 additions and 7 deletions

View File

@ -5,6 +5,7 @@ require (
github.com/gorilla/websocket v1.4.0
github.com/lib/pq v1.0.0
github.com/mattn/go-sqlite3 v1.10.0
github.com/mjibson/esc v0.1.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/sirupsen/logrus v1.3.0
github.com/stretchr/testify v1.2.2

View File

@ -10,6 +10,8 @@ github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mjibson/esc v0.1.0 h1:5ch+murgrcwDFLOE2hwj0f7kE4xJfJhkSCAjSLY182o=
github.com/mjibson/esc v0.1.0/go.mod h1:9Hw9gxxfHulMF5OJKCyhYD7PzlSdhzXyaGEBRPH1OPs=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

View File

@ -32,12 +32,17 @@ type MapObject struct {
}
func NewMapObject(MBPos *coords.MapBlockCoords, x int, y int, z int, _type string) *MapObject {
if x > 16 || y > 16 || z > 16 {
panic("Out of range3!") //XXX
}
o := MapObject{
MBPos: MBPos,
Type: _type,
X: MBPos.X + x,
Y: MBPos.Y + y,
Z: MBPos.Z + z,
X: (MBPos.X * 16) + x,
Y: (MBPos.Y * 16) + y,
Z: (MBPos.Z * 16) + z,
Mtime: time.Now().Unix(),
Attributes: make(map[string]string),
}

View File

@ -32,6 +32,8 @@ api.getConfig().then(function(cfg){
overlays["Players"] = new PlayerOverlay(wsChannel, layerMgr);
overlays["Travelnet"] = new TravelnetOverlay(wsChannel, layerMgr);
map.addLayer(overlays["Players"]);
L.control.layers(layers, overlays).addTo(map);
var el = new CoordinatesDisplay({ position: 'bottomleft' });

View File

@ -16,7 +16,7 @@ var AbstractIconOverlay = L.LayerGroup.extend({
},
hashPos: function(x,y,z){
return x + "/" + y "/" + z;
return x + "/" + y + "/" + z;
},
onLayerChange: function(layer){
@ -69,7 +69,7 @@ var AbstractIconOverlay = L.LayerGroup.extend({
} else {
//marker does not exist
var marker = L.marker([obj.z, obj.x], {icon: self.icon});
marker.bindPopup(self.getPopup(obj));
marker.bindPopup(self.createPopup(obj));
marker.addTo(self);
self.currentObjects[hash] = marker;

View File

@ -8,9 +8,9 @@ var TravelnetIcon = L.icon({
popupAnchor: [0, -32]
});
var TravelnetOverlay = L.AbstractIconOverlay.extend({
var TravelnetOverlay = AbstractIconOverlay.extend({
initialize: function(wsChannel, layerMgr) {
L.AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "travelnet", TravelnetIcon);
AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "travelnet", TravelnetIcon);
},
createPopup: function(travelnet){