Skip to content

Commit f383188

Browse files
author
corvis
committed
Added autosize method
1 parent f2061de commit f383188

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/locationpicker.jquery.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@
212212
}
213213
}
214214

215+
function autosize(gmapContext) {
216+
google.maps.event.trigger(gmapContext.map, 'resize');
217+
setTimeout(function() {
218+
gmapContext.map.setCenter(gmapContext.marker.position);
219+
}, 300);
220+
}
221+
215222
/**
216223
* Initialization:
217224
* $("#myMap").locationpicker(options);
@@ -269,7 +276,7 @@
269276
* marker: marker placed on map
270277
* }
271278
*/
272-
if (params == undefined) { // Getter is not available
279+
if (params == undefined) { // Getter
273280
var locationObj = GmUtility.locationFromLatLng(gmapContext.location);
274281
locationObj.formattedAddress = gmapContext.locationName;
275282
locationObj.addressComponents = gmapContext.addressComponents;
@@ -278,9 +285,12 @@
278285
marker: gmapContext.marker,
279286
location: locationObj
280287
}
281-
} else {
288+
} else { // Setter is not available
282289
return null;
283290
}
291+
case "autosize":
292+
autosize(gmapContext);
293+
return this;
284294
}
285295
return null;
286296
}
@@ -316,8 +326,6 @@
316326
});
317327
GmUtility.setPosition(gmapContext, new google.maps.LatLng(settings.location.latitude, settings.location.longitude), function(context){
318328
updateInputValues(settings.inputBinding, gmapContext);
319-
var currentLocation = GmUtility.locationFromLatLng(gmapContext.location);
320-
//settings.onchanged.apply(gmapContext.domContainer, [currentLocation, context.radius, false]);
321329
// Set up input bindings if needed
322330
setupInputListenersInput(settings.inputBinding, gmapContext);
323331
context.settings.oninitialized($target);

0 commit comments

Comments
 (0)