Compare commits

...

2 Commits

Author SHA1 Message Date
jack77213 bb1a6ff2cd
fix 2020-03-02 20:02:24 +08:00
jack77213 056d65c67f
multimap 2020-03-02 19:13:13 +08:00
3 changed files with 15 additions and 5 deletions

View File

@ -1,8 +1,10 @@
import L from 'leaflet';
import 'leaflet/dist/leaflet.css';
import * as marker from './marker.js';
import mapsize from './mapsize.js';
let bounds = [[0,0], [-3840, 3840]];
let mapName = window.location.hash.slice(1)
let bounds = [[0,0], [-mapsize[mapName]/4, mapsize[mapName]/4]];
let map = L.map('map', {
crs: L.CRS.Simple,
@ -10,13 +12,13 @@ let map = L.map('map', {
maxZoom: 4
});
L.tileLayer('./maps/build/{z}/x{x}_y{y}.jpg', {
L.tileLayer('./maps/'+mapName+'/{z}/x{x}_y{y}.jpg', {
minZoom: -1,
maxZoom: 4,
minNativeZoom: 1,
maxNativeZoom: 3,
tileSize: 1000,
bounds: [[0,0], [-3840, 3840]]
bounds: bounds
}).addTo(map);
// let image = L.imageOverlay('./maps/Tanoa.png', bounds).addTo(map);

5
ui/mapsize.js Normal file
View File

@ -0,0 +1,5 @@
export default {
"Tanoa": 15360,
"Enoch": 12800
}

View File

@ -1,4 +1,7 @@
import L from 'leaflet';
import mapsize from './mapsize.js';
let mapName = window.location.hash.slice(1);
const icon_types = {
"blue": "blue.png",
@ -18,7 +21,7 @@ function makeMarker(coord=[0, 0], icon='loc_blue', text='') {
});
let [x, y] = coord;
y = y/8 - (15360/8);
y = y/8 - (mapsize[mapName]/8);
x = x/8;
let marker = L.marker(L.latLng(y, x), {icon: markerIcon});
// https://gis.stackexchange.com/questions/59571/how-to-add-text-only-labels-on-leaflet-map-with-no-icon
@ -34,7 +37,7 @@ function makeUnitPos(coord=[0, 0], icon='purple') {
});
let [x, y] = coord;
y = y/8 - (15360/8);
y = y/8 - (mapsize[mapName]/8);
x = x/8;
let marker = L.marker(L.latLng(y, x), {icon: markerIcon});
return marker;