Skip to content

Commit

Permalink
map can set its maximum zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
tekig committed Aug 23, 2020
1 parent 5f85d3d commit 795cf13
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion web/option.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Operation Capture And Playback",
"author": "Frontend: MisterGoodson (aka Goodson [3CB]), Backend: Dell",
"language": "ru",
"version": "3.1.1",
"version": "3.2.0",
"listen": "127.0.0.1:5000",
"secret": "same-secret",
"logger": true,
Expand Down
28 changes: 20 additions & 8 deletions web/static/scripts/ocap.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class Entities {
var imageSize = null;
var multiplier = null;
var trim = 0; // Number of pixels that were trimmed when cropping image (used to correct unit placement)
var mapMinZoom = 1;
var mapMaxNativeZoom = 6;
var mapMaxZoom = mapMaxNativeZoom + 3;
var mapMinZoom = null;
var mapMaxNativeZoom = null;
var mapMaxZoom = null; // mapMaxNativeZoom + 3;
var map = null;
var mapDiv = null;
var mapPanes = null;
Expand Down Expand Up @@ -143,23 +143,36 @@ function setWorld() {

function getWorldByName(worldName) {
console.log("Getting world " + worldName);
let result;
let map = {};
let defaultMap = {
"name": "NOT FOUND",
"worldname": "NOT FOUND",
"worldSize": 16384,
"imageSize": 16384,
"multiplier": 1,
"maxZoom": 6,
"minZoom": 0,
};

$.ajax({
url: "images/maps/" + worldName + "/map.json",
async: false,
success: function (data) {
result = data;
map = data;
},
error: function () {
result = {"name": "NOT FOUND", "worldname": "NOT FOUND", "worldSize": 16384, "imageSize": 16384, "multiplier": 1};
ui.showHint(`Error: Map "${worldName}" is not installed`);
}
});
return result;

return Object.assign(defaultMap, map);
};

function initMap() {
var world = getWorldByName(worldName);
// Bad
mapMaxNativeZoom = world.maxZoom
mapMaxZoom = mapMaxNativeZoom + 3
// Create map
map = L.map('map', {
//maxZoom: mapMaxZoom,
Expand All @@ -184,7 +197,6 @@ function initMap() {
ui.hideMarkerPopups = false;
};
});
var world = getWorldByName(worldName);
console.log("Got world: ");
console.log(world);

Expand Down

0 comments on commit 795cf13

Please sign in to comment.