Fixed map not loding bug
This commit is contained in:
@@ -38,21 +38,37 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
function initMap() {
|
function initMap() {
|
||||||
map = new google.maps.Map(document.getElementById('map'), {
|
|
||||||
center: { lat: -34.397, lng: 150.644 },
|
|
||||||
zoom: 11,
|
|
||||||
restriction: {
|
|
||||||
latLngBounds: BOSNIA_BOUNDS,
|
|
||||||
strictBounds: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
var geocoder = new google.maps.Geocoder();
|
var geocoder = new google.maps.Geocoder();
|
||||||
|
|
||||||
document.getElementById('submit').addEventListener('click', function () {
|
document.getElementById('submit').addEventListener('click', function () {
|
||||||
geocodeAddress(geocoder, map, false, latLngRestrictions);
|
geocodeAddress(geocoder, map, false, latLngRestrictions);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
defaultAddress.value = municipality;
|
||||||
|
geocodeAddress(geocoder, map, true);
|
||||||
|
|
||||||
|
$(document).ready(() => {
|
||||||
|
$("#btnsubmit").click(() => {
|
||||||
|
var bounds = map.getBounds();
|
||||||
|
|
||||||
|
$("#north").val(map.getBounds().getNorthEast().lat());
|
||||||
|
$("#south").val(map.getBounds().getSouthWest().lat());
|
||||||
|
$("#east").val(map.getBounds().getNorthEast().lng());
|
||||||
|
$("#west").val(map.getBounds().getSouthWest().lng());
|
||||||
|
|
||||||
|
$("#form-map-output").submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function geocodeAddress(geocoder, resultsMap, isInit, geocoderRestrictions) {
|
function geocodeAddress(geocoder, resultsMap, isInit, geocoderRestrictions) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var address = document.getElementById('address').value;
|
var address = document.getElementById('address').value;
|
||||||
let geocoderOptions = geocoderRestrictions
|
let geocoderOptions = geocoderRestrictions
|
||||||
? { 'address': address, 'bounds': geocoderRestrictions }
|
? { 'address': address, 'bounds': geocoderRestrictions }
|
||||||
@@ -69,6 +85,13 @@
|
|||||||
results[0].geometry.viewport.getNorthEast()
|
results[0].geometry.viewport.getNorthEast()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isInit) {
|
||||||
|
map = new google.maps.Map(document.getElementById('map'), {
|
||||||
|
zoom: 11,
|
||||||
|
});
|
||||||
|
resultsMap = map
|
||||||
|
}
|
||||||
|
|
||||||
// map.fitBounds(resultBounds);
|
// map.fitBounds(resultBounds);
|
||||||
resultsMap.setCenter(results[0].geometry.location);
|
resultsMap.setCenter(results[0].geometry.location);
|
||||||
|
|
||||||
@@ -100,25 +123,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultAddress.value = municipality;
|
|
||||||
geocodeAddress(geocoder, map, true);
|
|
||||||
|
|
||||||
$(document).ready(() => {
|
|
||||||
$("#btnsubmit").click(() => {
|
|
||||||
var bounds = map.getBounds();
|
|
||||||
|
|
||||||
$("#north").val(map.getBounds().getNorthEast().lat());
|
|
||||||
$("#south").val(map.getBounds().getSouthWest().lat());
|
|
||||||
$("#east").val(map.getBounds().getNorthEast().lng());
|
|
||||||
$("#west").val(map.getBounds().getSouthWest().lng());
|
|
||||||
|
|
||||||
$("#form-map-output").submit();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAna8ohfV2HBMcxGk_29vqxU5Z_bDickqg&callback=initMap" async
|
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAna8ohfV2HBMcxGk_29vqxU5Z_bDickqg&callback=initMap" async
|
||||||
defer></script>
|
defer></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user