mirror of
https://github.com/jlengrand/leaflet-geosearch.git
synced 2026-03-10 08:31:26 +00:00
Merge pull request #67 from thataustin/patch-1
Fixing bug when Maps API already loaded
This commit is contained in:
@@ -6,7 +6,10 @@
|
||||
|
||||
onLoadGoogleApiCallback = function() {
|
||||
L.GeoSearch.Provider.Google.Geocoder = new google.maps.Geocoder();
|
||||
document.body.removeChild(document.getElementById('load_google_api'));
|
||||
var scriptNode = document.getElementById('load_google_api');
|
||||
if (!!scriptNode) {
|
||||
document.body.removeChild(scriptNode);
|
||||
}
|
||||
};
|
||||
|
||||
L.GeoSearch.Provider.Google = L.Class.extend({
|
||||
@@ -16,8 +19,13 @@ L.GeoSearch.Provider.Google = L.Class.extend({
|
||||
|
||||
initialize: function(options) {
|
||||
options = L.Util.setOptions(this, options);
|
||||
if (!window.google || !window.google.maps)
|
||||
this.loadMapsApi();
|
||||
if (!window.google || !window.google.maps) {
|
||||
this.loadMapsApi();
|
||||
} else {
|
||||
// if google is already loaded, make sure we initialize the Geocoder
|
||||
onLoadGoogleApiCallback();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
loadMapsApi: function () {
|
||||
|
||||
Reference in New Issue
Block a user