Widget:Dynamic Map

Dynamic Map
Use the following code to invoke:

Current Map Options: customs, woods

Press the "Edit source" button at the top-right to see the actual source code of the widget (not visible in viewing mode). WARNING: TO ADD A NEW MARKER ON THE MAP, DO NOT EDIT THIS FILE, USE THE TABLE IN THE PROPER WIKI PAGE

HOW TO EDIT THIS WIDGET:

You should no longer need to edit this widget



  //DONT TOUCH ME. I'M SENSITIVE "use strict"

var MapIcon = L.Icon.extend({   options: {        iconSize: [26, 26],        iconAnchor: [13, 13],        popupAnchor: [0, -7],        tooltipAnchor: [0, 0],        className: 'eft_map_icon'    } }) var leafletMapItems = {} var overlayLayers = [] var filterLayers = {} function addMapItem(skipAddingNewFilterOption, layerName, filterName, filterImageURL){ var filterCheckboxFormat = " " + layerName + "" var leafletMapItem = { leafletLayerName: layerName, leafletFilterCheckbox: filterCheckboxFormat, leafletLayerGroup: L.layerGroup, leafletMapIcon: new MapIcon({iconUrl: filterImageURL}), }   if (skipAddingNewFilterOption){ leafletMapItem.leafletLayerGroup = leafletMapItems[filterName].leafletLayerGroup leafletMapItems[layerName] = leafletMapItem }   else{ leafletMapItems[layerName] = leafletMapItem filterLayers[leafletMapItems[layerName].leafletFilterCheckbox] = leafletMapItems[layerName].leafletLayerGroup }   overlayLayers.push(leafletMapItems[layerName].leafletLayerGroup) } //console.log(leafletMapItems)

//- TRANSLATION TABLE AND STUFF HERE // Base URL and background console.log("test") var interactiveMapTableData = "" var mapBackground = "" var currentLangDomain = window.location.hostname var languageCode = 0 var languageDict = "" switch(currentLangDomain) { case 'escapefromtarkov.fandom.com': languageCode = 0 languageDict = "EN" break case 'escapefromtarkov.fandom.com/de/': languageCode = 1 languageDict = "DE" break case 'escapefromtarkov.fandom.com/fr/': languageCode = 2 languageDict = "FR" break case 'escapefromtarkov.fandom.com/ko/': languageCode = 3 languageDict = "KO" break case 'escapefromtarkov.fandom.com/ru/': languageCode = 4 languageDict = "RU" break default: languageCode = 0 languageDict = "EN" break }

var current_map = "" var interactiveMapIconNames = {} var interactiveMapIconImages = []

// Section for map specifics. Flash drives, scav snipers, quest related // Basically for more "special" things that don't appear on all maps // - var translated_extracts_name = '' var translated_quests_name = ''

// -

var bounds = [] $.ajax({   type: 'GET',    url: 'https://escapefromtarkov.fandom.com/api.php?action=parse&format=json&prop=text|Ã¢â‚¬â€¹links&page=Interactive_Map_Translation_Table&origin=*',    contentType: 'application/json charset=utf-8',    async: false,    dataType: 'json',    success: function(data) {        var html = data.parse.text['*']        if (!html) {            return console.log('no HTML')        }        var $hiddenContent = $(' ').html(data.parse.text['*']).hide        var translationData = $hiddenContent.find('table.sortable tr').map(function { return new Array($('td', this).map(function { return $(this).text.replace(/\n/g, '').trim }).slice(0, 9).get) }).get       $hiddenContent.remove        var map_column = ''        for (var i in translationData) {            if (i == 0) {                switch(current_map) {                    case 'customs':                        bounds = -2142, -4096],[2142, 4096                        map_column = 6                        mapBackground = "https://static.wikia.nocookie.net/escapefromtarkov_gamepedia/images/9/9a/Customs_map_glory4lyfe.png/revision/latest"                        interactiveMapTableData = "Customs_Interactive_Map_Table"                        break                    case 'woods':                        bounds = -3601, -5401],[3601, 5401                        map_column = 7                        mapBackground = "https://static.wikia.nocookie.net/escapefromtarkov_gamepedia/images/0/08/Glory4lyfeWoods_map_v4.png/revision/latest"                        interactiveMapTableData = "Woods_Interactive_Map_Table" break default: map_column = 6 }               continue }           if (translationData[i][map_column] == 'x'){ if (translationData[i][0] == 'Extracts'){ translated_extracts_name = translationData[i][languageCode] }               if (translationData[i][0] == 'Quest Related'){

translated_quests_name = translationData[i][languageCode] }               interactiveMapIconNames[translationData[i][0]] = translationData[i][languageCode] interactiveMapIconImages.push(translationData[i][5]) }       } }, // End of success function AJAX error: function(error) { return console.log(error) } }) var i = -1 for (var key in interactiveMapIconNames){   i = i + 1    addMapItem(false, interactiveMapIconNames[key], '', interactiveMapIconImages[i]) } addMapItem(true, 'PMC Extract', translated_extracts_name, "https://static.wikia.nocookie.net/escapefromtarkov_gamepedia/images/9/9a/Interactive_map_pmc_extract_8x.png/revision/latest") addMapItem(true, 'SCAV Extract', translated_extracts_name, "https://static.wikia.nocookie.net/escapefromtarkov_gamepedia/images/8/87/Interactive_map_scav_extract_8x.png/revision/latest") addMapItem(true, 'ALL Extract', translated_extracts_name, "https://static.wikia.nocookie.net/escapefromtarkov_gamepedia/images/1/10/Interactive_map_extract_both.png/revision/latest") addMapItem(true, 'Safari Quest', translated_quests_name, "https://static.wikia.nocookie.net/escapefromtarkov_gamepedia/images/6/60/Interactive_Map_safari.png/revision/latest") addMapItem(true, 'BP Depot Quest', translated_quests_name, "https://static.wikia.nocookie.net/escapefromtarkov_gamepedia/images/5/58/Oil_truck_map.png/revision/latest") addMapItem(true, 'Checking Quest', translated_quests_name, "https://static.wikia.nocookie.net/escapefromtarkov_gamepedia/images/1/1e/Bronze_watch_map.png/revision/latest")

 



.leaflet-container { background-color:rgba(255,0,0,0.0); }   .map-scroll:before { content: 'Use SHIFT + mouse wheel to zoom the map \a Use CTRL + click to get coordinates'; font-family: "Arial Black", Gadget, sans-serif; white-space: pre; position: absolute; -webkit-text-stroke-width: 2px; -webkit-text-stroke-color: black; top: 0%; left: 5%; z-index: 999; font-size: 30px; }

.leaflet-bar button, .leaflet-bar button:hover { background-color: #fff; border: none; border-bottom: 1px solid #ccc; width: 100%; height: 26px; line-height: 26px; display: inline-block; text-align: center; text-decoration: none; color: black; }

.leaflet-bar button { background-position: 50% 50%; background-repeat: no-repeat; overflow: hidden; display: inline-block; }

.leaflet-bar button:hover { background-color: #f4f4f4; }

.leaflet-bar button:first-of-type { border-top-left-radius: 4px; border-top-right-radius: 4px; }

.leaflet-bar button:last-of-type { border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-bottom: none; }

.leaflet-bar.disabled, .leaflet-bar button.disabled { display: none; }

.easy-button-button .button-state{ display: inline-block; width: 100%; height: 100%; position: relative; }

.leaflet-touch .leaflet-bar button { width: 100%; height: 30px; line-height: 30px; }

"use strict"

function turnLayersOn{ for (var i = 0; i < overlayLayers.length; ++i) { map.addLayer(overlayLayers[i]) } }

function turnLayersOff{ for (var i = 0; i < overlayLayers.length; ++i) { map.removeLayer(overlayLayers[i]) } }

var multilangDataTable = {} $.ajax({   type: 'GET',    url: 'https://escapefromtarkov.fandom.com/api.php?action=parse&prop=text&format=json&page=Multilanguage_Data_Table&origin=*',    contentType: 'application/json charset=utf-8',    async: false,    dataType: 'json',    success: function(data) {        var html = data.parse.text['*']        if (!html) {            return console.log('no HTML')        }        var $hiddenContent = $(' ').html(data.parse.text['*']).hide        var multilangData = $hiddenContent.find('table.sortable tr').map(function { return new Array($('td', this).map(function { return $(this).text.replace(/\n/g, '').trim }).slice(0, 9).get) }).get       $hiddenContent.remove

for (i in multilangData){ if (i == 0) { continue }           multilangDataTable[multilangData[i][0]] = { 0 : multilangData[i][0], 1 : multilangData[i][1], 2 : multilangData[i][2], 3 : multilangData[i][3], 4 : multilangData[i][4] }   } }, // End of success function AJAX error: function(error_alert) { return console.log(error_alert) } })

var dynamicPopUps = [] // Load the data for the map. $.ajax({   type: 'GET',    url: 'https://escapefromtarkov.fandom.com/api.php?action=parse&format=json&prop=text|Ã¢â‚¬â€¹links&page=' + interactiveMapTableData + '&origin=*',    contentType: 'application/json charset=utf-8',    async: false,    dataType: 'json',    success: function(data) {        var html = data.parse.text['*']        if (!html) {            return console.log('no HTML')        }        var $hiddenContent = $(' ').html(data.parse.text['*']).hide        var mapData = $hiddenContent.find('table.sortable tr').map(function { return new Array($('td', this).map(function { return $(this).text.replace(/\n/g, '').trim }).slice(0, 9).get) }).get       $hiddenContent.remove

for (var i in mapData) { if (i == 0) { continue }           var locationX = parseFloat(mapData[i][3]) || 0 var locationY = parseFloat(mapData[i][4]) || 0 var coordinatesXY = 'X: ' + locationX + ' Y: ' + locationY var popupContent = "" var internal_text = "" var filter_category = interactiveMapIconNames[mapData[i][0]] if (filter_category == null){ filter_category = mapData[i][0] if (mapData[i][0] == 'PMC Extract' || mapData[i][0] == 'SCAV Extract' || mapData[i][0] == 'ALL Extract'){ if (languageDict != "EN"){ var regex_patt_string = "(" + languageDict + ":)(.*)" const regex_patt = new RegExp(regex_patt_string, "i") var regex_result = mapData[i][2].match(regex_patt) popupContent = ' ' + regex_result[2] + ' [' + coordinatesXY + '] ' }                   else{ popupContent = ' ' + mapData[i][1] + '<\/strong> [' + coordinatesXY + '] ' }               }                else{ //console.log(mapData[i][0] + ' ' + mapData[i][1]) popupContent = ' ' + mapData[i][1] + ' [' + coordinatesXY + '] ' }               if (mapData[i][5] != "") { popupContent += '  [' + coordinatesXY + '] ' }               var currentPopUp = { popupFilterName: filter_category, popupX: locationY, popupY: locationX, popupContent: popupContent }               dynamicPopUps.push(currentPopUp) }           else{ if (mapData[i][1] != "" && multilangDataTable[mapData[i][1]]) { if (multilangDataTable[mapData[i][1]][languageCode]){ internal_text = multilangDataTable[mapData[i][1]][languageCode] popupContent = " " + internal_text + "  " }                   else{ popupContent = ' ' + filter_category + ' ' }               }                else{ popupContent = ' ' + filter_category + ' ' }               if (mapData[i][2] != "") { popupContent += mapData[i][2] + " " }               if (mapData[i][5] != "") { popupContent += ' [' + coordinatesXY + '] ' }               else { popupContent += ' [' + coordinatesXY + '] ' }               var currentPopUp = { popupFilterName: filter_category, popupX: locationY, popupY: locationX, popupContent: popupContent }               dynamicPopUps.push(currentPopUp) }       } }, // End of success function AJAX error: function { return console.log("error") } })

// Define the map and options for it. var map = L.map('map', {   crs: L.CRS.Simple,    minZoom: -4,    maxZoom: 1,    fullscreenControl: true,    zoomDelta: 0.25,    zoomSnap: 0.15,    wheelPxPerZoomLevel: 175,    layers: overlayLayers })

// Provide the full URL to the map image that has been uploaded. var image = L.imageOverlay(mapBackground, bounds).addTo(map) map.fitBounds(bounds)

var legendToggleBool = false; var legendToggleBtn = L.easyButton(" Legend On/Off<\/div>", function(btn, map){   if(legendToggleBool) {        legendToggleBool = false        disableAllBtn.enable        enableAllBtn.enable        controlLayers.addTo(map)    }     else {        legendToggleBool = true        disableAllBtn.disable        enableAllBtn.disable        controlLayers.remove    } }, { position: "topleft"}).addTo(map)

var enableAllBtn = L.easyButton(" Enable All", function(btn, map){   turnLayersOn }, { position: "topleft"})

var disableAllBtn = L.easyButton('Disable All<\/div>', function(btn, map){   turnLayersOff }, { position: "topleft"})

var zoomBar = L.easyBar([ enableAllBtn, disableAllBtn, ]) zoomBar.addTo(map) var baseMaps = {} var controlLayers = L.control.layers(baseMaps, filterLayers, {   "sortLayers": false,    "collapsed": false,    position: 'topleft' }).addTo(map)

map.setView([0, 0], -2.0)

// Build the Popups var regex_patt_btag = "(.*)(<\/strong>)" const regex_btag = new RegExp(regex_patt_btag, "i") var regex_result = '' for (var i = 0; i < dynamicPopUps.length; ++i){ if (leafletMapItems.hasOwnProperty(dynamicPopUps[i].popupFilterName)){ var leafletPopup = L.marker(           [dynamicPopUps[i].popupX, dynamicPopUps[i].popupY],             {icon: leafletMapItems[dynamicPopUps[i].popupFilterName].leafletMapIcon}        ) regex_result = '' switch(dynamicPopUps[i].popupFilterName) { case 'PMC Extract': regex_result = dynamicPopUps[i].popupContent.match(regex_btag) leafletPopup.bindTooltip(regex_result[2], {                   direction: "center",                    permanent: true,                     className: "pmc-extract",                     offset: [0, -20]                }); break case 'SCAV Extract': regex_result = dynamicPopUps[i].popupContent.match(regex_btag) leafletPopup.bindTooltip(regex_result[2], {                   direction: "center",                    permanent: true,                     className: "scav-extract",                     offset: [0, -20]                }); break case 'ALL Extract': regex_result = dynamicPopUps[i].popupContent.match(regex_btag) leafletPopup.bindTooltip(regex_result[2], {                   direction: "center",                    permanent: true,                     className: "all-extract",                     offset: [0, -20]                }); break }       leafletPopup.addTo(leafletMapItems[dynamicPopUps[i].popupFilterName].leafletLayerGroup).bindPopup(dynamicPopUps[i].popupContent) } }

$(".pmc-extract").css({   "background": "transparent",    "font-size": 16,    "font-weight": "bold",    "border": "none",    "box-shadow": "none",    "color": "#00e599",    "text-shadow": "0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white" })

$(".scav-extract").css({   "background": "transparent",    "font-size": 16,    "font-weight": "bold",    "border": "none",    "box-shadow": "none",    "color": "#fdac00",    "text-shadow": "0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white" })

$(".all-extract").css({   "background": "transparent",    "font-size": 16,    "font-weight": "bold",    "border": "none",    "box-shadow": "none",    "color": "#61d0fd",    "text-shadow": "0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white, 0 0 10px white" })

//disable default scroll to use CTRL map.scrollWheelZoom.disable map.on('click', function(e) {   if (e.originalEvent.ctrlKey) {        var locationX = e.latlng.lng        var locationY = e.latlng.lat        this.openTooltip("X: " + locationX.toFixed(0) + "Y: " + locationY.toFixed(0), e.latlng)    } })

map.on('zoomend', function {   var calculated_icon_val = 5 * (map.getZoom) + 25    var height_width =  + calculated_icon_val +'px'    var margin_top_left =  + -Math.abs(calculated_icon_val / 2) +'px'    $('.eft_map_icon').css({ 'width': height_width, 'height': height_width, 'margin-left': margin_top_left, 'margin-top': margin_top_left, })   // $(".pmc-extract").css({ //    "font-size": Math.abs(Math.abs(calculated_icon_val / 2)) // }) })

map.on('overlayadd', function {   var calculated_icon_val = 5 * (map.getZoom) + 25    var height_width =  + calculated_icon_val +'px'    var margin_top_left =  + -Math.abs(calculated_icon_val / 2) +'px'    $('.eft_map_icon').css({ 'width': height_width, 'height': height_width, 'margin-left': margin_top_left, 'margin-top': margin_top_left, }) })

$("#map").bind('mousewheel DOMMouseScroll', function(event) {   event.stopPropagation    if (event.shiftKey == true) {        event.preventDefault        map.scrollWheelZoom.enable        $('#map').removeClass('map-scroll')        setTimeout(function { map.scrollWheelZoom.disable }, 1000)   }     else {        map.scrollWheelZoom.disable        $('#map').addClass('map-scroll')    } }) $(window).bind('mousewheel DOMMouseScroll', function(event) {       $('#map').removeClass('map-scroll') })