Merge pull request #50 from minetest-tools/dependabot/go_modules/github.com/stretchr/testify-1.4.0
Bump github.com/stretchr/testify from 1.2.2 to 1.4.0
This commit is contained in:
commit
17b06037e4
2
Makefile
2
Makefile
@ -36,7 +36,7 @@ clean:
|
||||
rm -rf $(OUT_DIR)
|
||||
|
||||
jshint:
|
||||
jshint static/js/*.js static/js/util static/js/overlays static/js/search
|
||||
jshint static/js/*.js static/js/components static/js/map static/js/util
|
||||
|
||||
$(STATIC_VFS):
|
||||
go generate
|
||||
|
2
go.mod
2
go.mod
@ -9,7 +9,7 @@ require (
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/prometheus/client_golang v0.9.4
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/stretchr/testify v1.2.2
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583
|
||||
golang.org/x/image v0.0.0-20190118043309-183bebdce1b2 // indirect
|
||||
)
|
||||
|
10
go.sum
10
go.sum
@ -2,6 +2,7 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
@ -19,6 +20,7 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
@ -57,13 +59,16 @@ github.com/prometheus/client_golang v0.9.4/go.mod h1:oCXIBxdI62A4cR6aTRJCgetEjec
|
||||
github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8=
|
||||
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE=
|
||||
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=
|
||||
@ -71,10 +76,13 @@ github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 h1:SZPG5w7Qxq7bMcMVl6e3Ht2X7f+AAGQdzjkbyOnNNZ8=
|
||||
github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
|
||||
@ -98,3 +106,5 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
@ -1,10 +1,13 @@
|
||||
body {
|
||||
height: 100%;
|
||||
height: 98%;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#image-map {
|
||||
#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.full-screen {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1px solid #ccc;
|
||||
@ -16,15 +19,6 @@ body {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#search-menu {
|
||||
position: absolute;
|
||||
top: 5%;
|
||||
bottom: 5%;
|
||||
left: 5%;
|
||||
right: 5%;
|
||||
z-index: 99999;
|
||||
}
|
||||
|
||||
.mapserver-label-icon {
|
||||
margin-left: -100px !important;
|
||||
margin-top: -100px !important;
|
||||
|
@ -15,8 +15,7 @@
|
||||
<title>Minetest Mapserver</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="image-map"></div>
|
||||
<div id="search-content"></div>
|
||||
<div id="app"></div>
|
||||
|
||||
<!-- libraries -->
|
||||
<script src="js/lib/mithril.min.js"></script>
|
||||
|
@ -1,59 +0,0 @@
|
||||
|
||||
export default {
|
||||
|
||||
setup: function(map, layerMgr){
|
||||
function updateHash(){
|
||||
var center = map.getCenter();
|
||||
window.location.hash =
|
||||
layerMgr.getCurrentLayer().id + "/" +
|
||||
center.lng + "/" + center.lat + "/" + map.getZoom();
|
||||
}
|
||||
|
||||
map.on('zoomend', updateHash);
|
||||
map.on('moveend', updateHash);
|
||||
map.on('baselayerchange', updateHash);
|
||||
updateHash();
|
||||
},
|
||||
|
||||
getLayerId: function(){
|
||||
var hashParts = window.location.hash.substring(1).split("/");
|
||||
if (hashParts.length == 4){
|
||||
//new format
|
||||
return +hashParts[0];
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
getZoom: function(){
|
||||
var hashParts = window.location.hash.substring(1).split("/");
|
||||
if (hashParts.length == 3){
|
||||
//old format
|
||||
return +hashParts[2];
|
||||
|
||||
} else if (hashParts.length == 4){
|
||||
//new format
|
||||
return +hashParts[3];
|
||||
|
||||
}
|
||||
|
||||
return 11;
|
||||
},
|
||||
|
||||
getCenter: function(){
|
||||
var hashParts = window.location.hash.substring(1).split("/");
|
||||
if (hashParts.length == 3){
|
||||
//old format
|
||||
return [+hashParts[1], +hashParts[0]];
|
||||
|
||||
} else if (hashParts.length == 4){
|
||||
//new format
|
||||
return [+hashParts[2], +hashParts[1]];
|
||||
|
||||
}
|
||||
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
};
|
15
static/js/compat.js
Normal file
15
static/js/compat.js
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
export function hashCompat(){
|
||||
|
||||
if (window.location.hash) {
|
||||
let match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)$/m);
|
||||
if (match) {
|
||||
window.location.hash = `#!/map/0/${match[1]}/${match[2]}/${match[3]}`;
|
||||
}
|
||||
|
||||
match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)\/(\d*)$/m);
|
||||
if (match) {
|
||||
window.location.hash = `#!/map/${match[1]}/${match[2]}/${match[3]}/${match[4]}`;
|
||||
}
|
||||
}
|
||||
}
|
51
static/js/components/Map.js
Normal file
51
static/js/components/Map.js
Normal file
@ -0,0 +1,51 @@
|
||||
import layerManager from '../map/LayerManager.js';
|
||||
import { createMap } from '../map/MapFactory.js';
|
||||
|
||||
export default {
|
||||
view(){
|
||||
return m("div", { class: "full-screen" });
|
||||
},
|
||||
|
||||
oncreate(vnode){
|
||||
|
||||
const map = createMap(
|
||||
vnode.dom,
|
||||
+vnode.attrs.layerId,
|
||||
+vnode.attrs.zoom,
|
||||
+vnode.attrs.lat,
|
||||
+vnode.attrs.lon
|
||||
);
|
||||
|
||||
vnode.state.map = map;
|
||||
|
||||
function updateHash(){
|
||||
const center = map.getCenter();
|
||||
const layerId = layerManager.getCurrentLayer().id;
|
||||
|
||||
m.route.set(`/map/${layerId}/${map.getZoom()}/${center.lng}/${center.lat}`);
|
||||
}
|
||||
|
||||
map.on('zoomend', updateHash);
|
||||
map.on('moveend', updateHash);
|
||||
map.on('baselayerchange', updateHash);
|
||||
},
|
||||
|
||||
onbeforeupdate(newVnode) {
|
||||
const center = newVnode.state.map.getCenter();
|
||||
const newAattrs = newVnode.attrs;
|
||||
|
||||
return newAattrs.layerId != layerManager.getCurrentLayer().id ||
|
||||
newAattrs.zoom != newVnode.state.map.getZoom() ||
|
||||
Math.abs(newAattrs.lat - center.lat) > 0.1 ||
|
||||
Math.abs(newAattrs.lat - center.lat) > 0.1;
|
||||
},
|
||||
|
||||
onupdate(vnode){
|
||||
layerManager.switchLayer(+vnode.attrs.layerId);
|
||||
vnode.state.map.setView([+vnode.attrs.lat, +vnode.attrs.lon], +vnode.attrs.zoom);
|
||||
},
|
||||
|
||||
onremove(vnode){
|
||||
vnode.state.map.remove();
|
||||
}
|
||||
};
|
62
static/js/components/Search.js
Normal file
62
static/js/components/Search.js
Normal file
@ -0,0 +1,62 @@
|
||||
import SearchResult from './SearchResult.js';
|
||||
import { getMapObjects } from '../api.js';
|
||||
|
||||
const state = {
|
||||
busy: false,
|
||||
result: []
|
||||
};
|
||||
|
||||
function searchFor(type, key, valuelike){
|
||||
return getMapObjects({
|
||||
pos1: { x:-2048, y:-2048, z:-2048 },
|
||||
pos2: { x:2048, y:2048, z:2048 },
|
||||
type: type,
|
||||
attributelike: {
|
||||
key: key,
|
||||
value: "%" + valuelike +"%"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function search(query){
|
||||
state.result = [];
|
||||
|
||||
var prom_list = [
|
||||
searchFor("shop", "out_item", query),
|
||||
searchFor("poi", "name", query),
|
||||
searchFor("train", "station", query),
|
||||
searchFor("travelnet", "station_name", query),
|
||||
searchFor("bones", "owner", query),
|
||||
searchFor("locator", "name", query),
|
||||
searchFor("label", "text", query),
|
||||
searchFor("digiterm", "display_text", query),
|
||||
searchFor("digilinelcd", "text", query)
|
||||
];
|
||||
|
||||
Promise.all(prom_list)
|
||||
.then(function(results){
|
||||
|
||||
var arr = [];
|
||||
results.forEach(function(r) {
|
||||
arr = arr.concat(r);
|
||||
});
|
||||
|
||||
state.result = arr;
|
||||
state.busy = false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export default {
|
||||
oncreate(vnode){
|
||||
search(vnode.attrs.query);
|
||||
},
|
||||
|
||||
view(vnode){
|
||||
if (state.result.length == 0) {
|
||||
return m("div", vnode.attrs.query);
|
||||
} else {
|
||||
return m(SearchResult, { result: state.result });
|
||||
}
|
||||
}
|
||||
};
|
@ -1,31 +1,34 @@
|
||||
import SearchStore from './SearchStore.js';
|
||||
import SearchService from './SearchService.js';
|
||||
|
||||
const state = {
|
||||
query: ""
|
||||
};
|
||||
|
||||
function doSearch(){
|
||||
m.route.set(`/search/${state.query}`);
|
||||
}
|
||||
|
||||
export default {
|
||||
view: function(){
|
||||
|
||||
function handleInput(e){
|
||||
SearchStore.query = e.target.value;
|
||||
state.query = e.target.value;
|
||||
}
|
||||
|
||||
function handleKeyDown(e){
|
||||
if (e.keyCode == 13){
|
||||
SearchService.search();
|
||||
doSearch();
|
||||
}
|
||||
}
|
||||
|
||||
function handleDoSearch(){
|
||||
SearchService.search();
|
||||
}
|
||||
|
||||
return m("div", { class: "input-group mb-3" }, [
|
||||
m("input[type=text]", {
|
||||
placeholder: "Search",
|
||||
class: "form-control",
|
||||
oninput: handleInput,
|
||||
onkeydown: handleKeyDown,
|
||||
value: SearchStore.query
|
||||
value: state.query
|
||||
}),
|
||||
m("div", { class: "input-group-append", onclick: handleDoSearch }, [
|
||||
m("div", { class: "input-group-append", onclick: doSearch }, [
|
||||
m("span", { class: "input-group-text" }, [
|
||||
m("i", { class: "fa fa-search"})
|
||||
])
|
@ -1,9 +1,8 @@
|
||||
import SearchStore from './SearchStore.js';
|
||||
import layerMgr from '../LayerManager.js';
|
||||
import layerMgr from '../map/LayerManager.js';
|
||||
|
||||
export default {
|
||||
view: function(vnode){
|
||||
var map = vnode.attrs.map;
|
||||
var result = vnode.attrs.result;
|
||||
|
||||
function getLayer(obj){
|
||||
var layer = layerMgr.getLayerByY(obj.y);
|
||||
@ -16,7 +15,7 @@ export default {
|
||||
return m("span", {class:"badge badge-success"}, text);
|
||||
}
|
||||
|
||||
var rows = SearchStore.result.map(function(obj){
|
||||
var rows = result.map(function(obj){
|
||||
|
||||
var row_classes = "";
|
||||
var description = obj.type;
|
||||
@ -120,11 +119,7 @@ export default {
|
||||
|
||||
function onclick(){
|
||||
var layer = layerMgr.getLayerByY(obj.y);
|
||||
|
||||
layerMgr.switchLayer(layer.id);
|
||||
|
||||
map.setView([obj.z, obj.x], 12);
|
||||
SearchStore.show = false;
|
||||
m.route.set(`/map/${layer.id}/${12}/${obj.x}/${obj.z}`);
|
||||
}
|
||||
|
||||
return m("tr", {"class": row_classes}, [
|
12
static/js/config.js
Normal file
12
static/js/config.js
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
var config;
|
||||
|
||||
export default {
|
||||
get(){
|
||||
return config;
|
||||
},
|
||||
|
||||
set(cfg){
|
||||
config = cfg;
|
||||
}
|
||||
};
|
@ -1,5 +1,18 @@
|
||||
|
||||
import { getConfig } from './api.js';
|
||||
import { setup } from './map.js';
|
||||
import routes from './routes.js';
|
||||
import wsChannel from './WebSocketChannel.js';
|
||||
import config from './config.js';
|
||||
import { hashCompat } from './compat.js';
|
||||
import layerManager from './map/LayerManager.js';
|
||||
|
||||
getConfig().then(setup);
|
||||
// hash route compat
|
||||
hashCompat();
|
||||
|
||||
getConfig().then(cfg => {
|
||||
|
||||
layerManager.setup(cfg.layers);
|
||||
config.set(cfg);
|
||||
wsChannel.connect();
|
||||
m.route(document.getElementById("app"), "/map/0/12/0/0", routes);
|
||||
});
|
||||
|
48
static/js/map/CustomOverlay.js
Normal file
48
static/js/map/CustomOverlay.js
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
var customOverlays = {};
|
||||
|
||||
try {
|
||||
customOverlays = JSON.parse(localStorage["mapserver-customOverlays"]);
|
||||
} catch (e){}
|
||||
|
||||
function save(){
|
||||
localStorage["mapserver-customOverlays"] = JSON.stringify(customOverlays);
|
||||
}
|
||||
|
||||
function onAddLayer(e){
|
||||
customOverlays[e.name] = true;
|
||||
save();
|
||||
}
|
||||
|
||||
function onRemoveLayer(e){
|
||||
customOverlays[e.name] = false;
|
||||
save();
|
||||
}
|
||||
|
||||
export default function(map, overlays){
|
||||
|
||||
Object.keys(customOverlays)
|
||||
.filter(name => overlays[name])
|
||||
.forEach(name => {
|
||||
const layer = overlays[name];
|
||||
|
||||
if (customOverlays[name] && !map.hasLayer(layer)){
|
||||
//Add
|
||||
map.addLayer(layer);
|
||||
}
|
||||
|
||||
if (!customOverlays[name] && map.hasLayer(layer)){
|
||||
//Remove
|
||||
map.removeLayer(layer);
|
||||
}
|
||||
});
|
||||
|
||||
map.on('unload', () => {
|
||||
map.off('overlayadd', onAddLayer);
|
||||
map.off('overlayremove', onRemoveLayer);
|
||||
});
|
||||
|
||||
map.on('overlayadd', onAddLayer);
|
||||
map.on('overlayremove', onRemoveLayer);
|
||||
|
||||
}
|
@ -2,17 +2,20 @@ import RealtimeTileLayer from './RealtimeTileLayer.js';
|
||||
|
||||
class LayerManager {
|
||||
|
||||
setup(wsChannel, layers, map, currentLayerId){
|
||||
setup(layers){
|
||||
this.listeners = [];
|
||||
this.currentLayer = layers[0];
|
||||
this.layers = layers;
|
||||
this.currentLayer = this.layers[0];
|
||||
}
|
||||
|
||||
setupMap(wsChannel, map, currentLayerId){
|
||||
this.map = map;
|
||||
this.layerObjects = {};
|
||||
|
||||
var self = this;
|
||||
|
||||
//All layers
|
||||
layers.forEach(function(layer){
|
||||
this.layers.forEach(function(layer){
|
||||
var tileLayer = new RealtimeTileLayer(wsChannel, layer.id, map);
|
||||
self.layerObjects[layer.name] = tileLayer;
|
||||
if (layer.id == currentLayerId){
|
@ -1,21 +1,23 @@
|
||||
import wsChannel from './WebSocketChannel.js';
|
||||
import Hashroute from './Hashroute.js';
|
||||
import wsChannel from '../WebSocketChannel.js';
|
||||
import SimpleCRS from './SimpleCRS.js';
|
||||
import CoordinatesDisplay from './CoordinatesDisplay.js';
|
||||
import WorldInfoDisplay from './WorldInfoDisplay.js';
|
||||
import SearchControl from './SearchControl.js';
|
||||
import Overlaysetup from './Overlaysetup.js';
|
||||
import CustomOverlay from './CustomOverlay.js';
|
||||
import layerManager from './LayerManager.js';
|
||||
import config from '../config.js';
|
||||
|
||||
export function setup(cfg){
|
||||
|
||||
wsChannel.connect();
|
||||
export function createMap(node, layerId, zoom, lat, lon){
|
||||
|
||||
var map = L.map('image-map', {
|
||||
const cfg = config.get();
|
||||
|
||||
const map = L.map(node, {
|
||||
minZoom: 2,
|
||||
maxZoom: 12,
|
||||
center: Hashroute.getCenter(),
|
||||
zoom: Hashroute.getZoom(),
|
||||
center: [lat, lon],
|
||||
zoom: zoom,
|
||||
crs: SimpleCRS
|
||||
});
|
||||
|
||||
@ -23,10 +25,11 @@ export function setup(cfg){
|
||||
|
||||
var overlays = {};
|
||||
|
||||
layerManager.setup(wsChannel, cfg.layers, map, Hashroute.getLayerId());
|
||||
layerManager.setupMap(wsChannel, map, layerId);
|
||||
|
||||
//All overlays
|
||||
Overlaysetup(cfg, map, overlays, wsChannel, layerManager);
|
||||
CustomOverlay(map, overlays);
|
||||
|
||||
new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map);
|
||||
new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map);
|
||||
@ -38,5 +41,5 @@ export function setup(cfg){
|
||||
//layer control
|
||||
L.control.layers(layerManager.layerObjects, overlays, { position: "topright" }).addTo(map);
|
||||
|
||||
Hashroute.setup(map, layerManager);
|
||||
return map;
|
||||
}
|
@ -1,18 +1,13 @@
|
||||
import SearchMenu from './search/SearchMenu.js';
|
||||
import SearchInput from './search/SearchInput.js';
|
||||
import SearchInput from '../components/SearchInput.js';
|
||||
|
||||
export default L.Control.extend({
|
||||
initialize: function(wsChannel, opts) {
|
||||
L.Control.prototype.initialize.call(this, opts);
|
||||
},
|
||||
|
||||
onAdd: function(map) {
|
||||
onAdd: function() {
|
||||
var div = L.DomUtil.create('div');
|
||||
m.mount(div, SearchInput);
|
||||
m.mount(document.getElementById("search-content"), {
|
||||
view: () => m(SearchMenu, {map: map})
|
||||
});
|
||||
|
||||
return div;
|
||||
}
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
import debounce from '../util/debounce.js';
|
||||
import { getMapObjects } from '../api.js';
|
||||
import debounce from '../../util/debounce.js';
|
||||
import { getMapObjects } from '../../api.js';
|
||||
|
||||
export default L.LayerGroup.extend({
|
||||
initialize: function(wsChannel, layerMgr, type) {
|
@ -1,5 +1,5 @@
|
||||
import debounce from '../util/debounce.js';
|
||||
import { getMapObjects } from '../api.js';
|
||||
import debounce from '../../util/debounce.js';
|
||||
import { getMapObjects } from '../../api.js';
|
||||
|
||||
export default L.LayerGroup.extend({
|
||||
initialize: function(wsChannel, layerMgr, type, icon) {
|
@ -1,5 +1,5 @@
|
||||
|
||||
m.mount(document.getElementById("image-map"), {
|
||||
m.mount(document.getElementById("app"), {
|
||||
view: function(){
|
||||
return m("div", "I'm sorry, your browser is just too old ;)");
|
||||
}
|
||||
|
15
static/js/routes.js
Normal file
15
static/js/routes.js
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
import Map from './components/Map.js';
|
||||
import Search from './components/Search.js';
|
||||
|
||||
var Home = {
|
||||
view: function() {
|
||||
return "Home";
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
"/": Home,
|
||||
"/map/:layerId/:zoom/:lon/:lat": Map,
|
||||
"/search/:query": Search
|
||||
};
|
@ -1,36 +0,0 @@
|
||||
|
||||
import SearchService from './SearchService.js';
|
||||
import SearchStore from './SearchStore.js';
|
||||
import SearchResult from './SearchResult.js';
|
||||
|
||||
export default {
|
||||
view: function(vnode){
|
||||
|
||||
var style = {};
|
||||
|
||||
if (!SearchStore.show) {
|
||||
style.display = "none";
|
||||
}
|
||||
|
||||
function close(){
|
||||
SearchService.clear();
|
||||
}
|
||||
|
||||
function getContent(){
|
||||
if (SearchStore.busy){
|
||||
return m("div", m("i", { class: "fa fa-spinner"}));
|
||||
} else {
|
||||
return m(SearchResult, { map: vnode.attrs.map });
|
||||
}
|
||||
}
|
||||
|
||||
return m("div", { class: "card", id: "search-menu", style: style }, [
|
||||
m("div", { class: "card-header" }, [
|
||||
m("i", { class: "fa fa-search"}),
|
||||
"Search",
|
||||
m("i", { class: "fa fa-times float-right", onclick: close }),
|
||||
]),
|
||||
m("div", { class: "card-body", style: {overflow: "auto"} }, getContent())
|
||||
]);
|
||||
}
|
||||
};
|
@ -1,62 +0,0 @@
|
||||
import SearchStore from './SearchStore.js';
|
||||
import { getMapObjects } from '../api.js';
|
||||
|
||||
export default {
|
||||
|
||||
search: function(){
|
||||
SearchStore.show = true;
|
||||
this.fetchData();
|
||||
},
|
||||
|
||||
fetchData: function(){
|
||||
SearchStore.result = [];
|
||||
|
||||
if (!SearchStore.query){
|
||||
return;
|
||||
}
|
||||
|
||||
SearchStore.busy = true;
|
||||
|
||||
function searchFor(type, key, valuelike){
|
||||
return getMapObjects({
|
||||
pos1: { x:-2048, y:-2048, z:-2048 },
|
||||
pos2: { x:2048, y:2048, z:2048 },
|
||||
type: type,
|
||||
attributelike: {
|
||||
key: key,
|
||||
value: "%" + valuelike +"%"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var prom_list = [
|
||||
searchFor("shop", "out_item", SearchStore.query),
|
||||
searchFor("poi", "name", SearchStore.query),
|
||||
searchFor("train", "station", SearchStore.query),
|
||||
searchFor("travelnet", "station_name", SearchStore.query),
|
||||
searchFor("bones", "owner", SearchStore.query),
|
||||
searchFor("locator", "name", SearchStore.query),
|
||||
searchFor("label", "text", SearchStore.query),
|
||||
searchFor("digiterm", "display_text", SearchStore.query),
|
||||
searchFor("digilinelcd", "text", SearchStore.query)
|
||||
];
|
||||
|
||||
Promise.all(prom_list)
|
||||
.then(function(results){
|
||||
|
||||
var arr = [];
|
||||
results.forEach(function(r) {
|
||||
arr = arr.concat(r);
|
||||
});
|
||||
|
||||
SearchStore.result = arr;
|
||||
SearchStore.busy = false;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
clear: function(){
|
||||
SearchStore.result = [];
|
||||
SearchStore.show = false;
|
||||
}
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
|
||||
export default {
|
||||
query: "",
|
||||
show: false,
|
||||
busy: false,
|
||||
result: []
|
||||
};
|
Loading…
Reference in New Issue
Block a user