Skip to content

Commit

Permalink
fix issue of map loading more than necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanTG committed Oct 14, 2024
1 parent 6129364 commit acc7572
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/assets/javascripts/application.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var numMachinesVal;
var locationTypeVal;
var single_id;
var mapAdjusted = 0;
var mapLoaded = 0;
var search_string;
var zoomLevel;
var markers = new Array();
Expand Down Expand Up @@ -67,14 +68,15 @@ function showLocations(ids, lats, lons, contents, num_machines, latLng) {
var map_style = map_style_obj;
}

if (mapAdjusted === 0) {
if (mapAdjusted === 0 && mapLoaded == 0) {
map = new maplibregl.Map({
container: 'map_canvas',
style: map_style
});
map.addControl(new maplibregl.ScaleControl({unit: 'imperial'}), 'bottom-right');
map.addControl(new maplibregl.NavigationControl(), 'bottom-right');
map.addControl(new maplibregl.FullscreenControl(), 'top-right');
mapLoaded = 1;
}

for (i in ids) {
Expand Down

0 comments on commit acc7572

Please sign in to comment.