I have a page with a button to open Maps in a modal. Since only few times the users will use this function I was wondering if it was possible to load the Google Maps library only if need (I prefer that user waits in this case instead of wait each time the page is loaded).
Thi is my modal:
<div class="modal" id="showBuildingsMaps" data-backdrop="static"
data-keyboard="false">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Select building</h4>
</div>
<div class="modal-body">
<div class="box-body" style="height: 80vh;">
<ng-map zoom="3" center="[{{selectedBuilding.latitude}}, {{selectedBuilding.longitude}}]" default-style="false">
<marker ng-repeat="m in markers" position="{{m.latitude}},{{m.longitude}}" title="{{m.name}}"
on-click="buildingFromMaps(m)"></marker> </ng-map>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
And there are several libraries of Google Maps:
<!-- Maps -->
<script
src="https://maps.googleapis.com/maps/api/js?key={myKey}"
type="text/javascript">
</script>
<!-- is useful to avoid google not found exception before this script was loaded bedore google maps -->
<script defer
th:src="@{/static/assets/plugins/angular-maps/ng-map.min.js}"
type="text/javascript"></script>
<script
src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/testapp/scripts/markerclusterer.js"
type="text/javascript"></script>
<script>
MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_
= 'https://raw.githubusercontent.com/googlemaps/js-marker-clusterer/gh-pages/images/m'; //changed image path
</script>