Skip to content

Commit

Permalink
various js/css fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
naturefreshmilk committed Dec 1, 2019
1 parent cad7f07 commit d2dff6d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 1 addition & 3 deletions static/css/custom.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
height: 98%;
height: 100%;
margin: 0;
}

Expand All @@ -10,8 +10,6 @@ body {
.full-screen {
width: 100%;
height: 100%;
border: 1px solid #ccc;
margin-bottom: 10px;
}

.leaflet-custom-display {
Expand Down
5 changes: 4 additions & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
<title>Minetest Mapserver</title>
</head>
<body>
<div id="app"></div>
<div id="app">
<br>
<h5 style="text-align: center;">Starting mapserver...</h5>
</div>

<!-- libraries -->
<script src="js/lib/mithril.min.js"></script>
Expand Down
15 changes: 10 additions & 5 deletions static/js/components/Map.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import layerManager from '../LayerManager.js';
import { createMap } from '../map/MapFactory.js';

function setupMap(vnode){
function setupMap(vnode, id){
const map = createMap(
vnode.dom,
id,
layerManager.getCurrentLayer().id,
+vnode.attrs.zoom,
+vnode.attrs.lat,
Expand All @@ -27,20 +27,25 @@ function setupMap(vnode){
}

export default {

oninit(){
this.id = "map_" + Math.floor(Math.random() * 10000);
},

view(){
return m("div", { class: "full-screen" });
return m("div", { class: "full-screen", id: this.id });
},

oncreate(vnode){
this.map = setupMap(vnode);
this.map = setupMap(vnode, this.id);
},

onupdate(vnode){
if (vnode.attrs.layerId != layerManager.getCurrentLayer().id){
//layer changed, recreate map
this.map.remove();
layerManager.setLayerId(vnode.attrs.layerId);
this.map = setupMap(vnode);
this.map = setupMap(vnode, this.id);

} else {
//position/zoom change
Expand Down
2 changes: 1 addition & 1 deletion static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ getConfig()
m.route(document.getElementById("app"), "/map/0/12/0/0", routes);
})
.catch(e => {
document.getElementById("app").innerHTML = JSON.stringify(e);
document.getElementById("app").innerHTML = e;
});
7 changes: 0 additions & 7 deletions static/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
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
};

0 comments on commit d2dff6d

Please sign in to comment.