Skip to content

Commit

Permalink
ESRI ArcGIS geo map support
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant committed May 23, 2024
1 parent f0966f4 commit 596dd48
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 4 deletions.
5 changes: 5 additions & 0 deletions html/js/esri-leaflet-vector.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions html/js/esri-leaflet.js

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions html/js/librenms.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,53 @@ function init_map(id, config = {}) {
(config.layer in baseMaps ? baseMaps[config.layer] : roads).addTo(leaflet);
leaflet.layerControl._container.style.display = (config.readonly ? 'none' : 'block');
});
} else if (config.engine === 'esri') {
leaflet.setMaxZoom(18);
// use vector maps if we have an API key
if (config.api_key) {
loadjs('js/esri-leaflet.js', function () {
loadjs('js/esri-leaflet-vector.js', function () {
var roads = L.esri.Vector.vectorBasemapLayer("ArcGIS:Streets", {
apikey: config.api_key
});
var topology = L.esri.Vector.vectorBasemapLayer("ArcGIS:Topographic", {
apikey: config.api_key
});
var satellite = L.esri.Vector.vectorBasemapLayer("ArcGIS:Imagery", {
apikey: config.api_key
});

baseMaps = {
"Streets": roads,
"Topography": topology,
"Satellite": satellite
};
leaflet.layerControl = L.control.layers(baseMaps, null, {position: 'bottomleft'}).addTo(leaflet);
(config.layer in baseMaps ? baseMaps[config.layer] : roads).addTo(leaflet);
leaflet.layerControl._container.style.display = (config.readonly ? 'none' : 'block');
});
});
} else {
let attribution = 'Powered by <a href="https://www.esri.com/">Esri</a> | Esri Community Maps Contributors, Maxar, Microsoft, Iowa DNR, © OpenStreetMap, Microsoft, TomTom, Garmin, SafeGraph, GeoTechnologies, Inc, METI/NASA, USGS, EPA, NPS, US Census Bureau, USDA, USFWS';
var roads = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
attribution: attribution
});
var topology = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x', {
attribution: attribution
});
var satellite = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: attribution
});

baseMaps = {
"Streets": roads,
"Topography": topology,
"Satellite": satellite
};
leaflet.layerControl = L.control.layers(baseMaps, null, {position: 'bottomleft'}).addTo(leaflet);
(config.layer in baseMaps ? baseMaps[config.layer] : roads).addTo(leaflet);
leaflet.layerControl._container.style.display = (config.readonly ? 'none' : 'block');
}
} else {
leaflet.setMaxZoom(20);
const tile_url = config.tile_url ? config.tile_url : '{s}.tile.openstreetmap.org';
Expand Down
12 changes: 8 additions & 4 deletions misc/config_definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,8 @@
"value": [
"google",
"mapquest",
"bing"
"bing",
"esri"
]
}
},
Expand All @@ -1856,7 +1857,8 @@
"google": "Google Maps",
"openstreetmap": "OpenStreetMap",
"mapquest": "MapQuest",
"bing": "Bing Maps"
"bing": "Bing Maps",
"esri": "ESRI ArcGIS"
}
},
"geoloc.latlng": {
Expand All @@ -1883,15 +1885,17 @@
"type": "select",
"options": {
"Streets": "Streets",
"Sattelite": "Sattelite"
"Sattelite": "Sattelite",
"Topography": "Topography"
},
"when": {
"setting": "geoloc.engine",
"operator": "in",
"value": [
"google",
"mapquest",
"bing"
"bing",
"esri"
]
}
},
Expand Down
1 change: 1 addition & 0 deletions resources/views/widgets/settings/worldmap.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<select class="form-control" name="init_layer" id="init_layer-{{ $id }}">
<option value="Streets" @if($init_layer == 'Streets') selected @endif>{{ __('Streets') }}</option>
<option value="Satellite" @if($init_layer == 'Satellite') selected @endif>{{ __('Satellite') }}</option>
<option value="Topography" @if($init_layer == 'Topography') selected @endif>{{ __('Topography') }}</option>
</select>
</div>

Expand Down

0 comments on commit 596dd48

Please sign in to comment.