219219 } , 300 ) ;
220220 }
221221
222+ function updateMap ( gmapContext , $target , options ) {
223+ var settings = $ . extend ( { } , $ . fn . locationpicker . defaults , options ) ,
224+ latNew = settings . location . latitude ,
225+ lngNew = settings . location . longitude ,
226+ radiusNew = settings . radius ,
227+ latOld = gmapContext . settings . location . latitude ,
228+ lngOld = gmapContext . settings . location . longitude ,
229+ radiusOld = gmapContext . settings . radius ;
230+
231+ if ( latNew == latOld && lngNew == lngOld && radiusNew == radiusOld )
232+ return ;
233+
234+ gmapContext . settings . location . latitude = latNew ;
235+ gmapContext . settings . location . longitude = lngNew ;
236+ gmapContext . radius = radiusNew ;
237+
238+ GmUtility . setPosition ( gmapContext , new google . maps . LatLng ( gmapContext . settings . location . latitude , gmapContext . settings . location . longitude ) , function ( context ) {
239+ setupInputListenersInput ( gmapContext . settings . inputBinding , gmapContext ) ;
240+ context . settings . oninitialized ( $target ) ;
241+ } ) ;
242+ }
222243 /**
223- * Initialization :
244+ * Initializeialization :
224245 * $("#myMap").locationpicker(options);
225246 * @param options
226247 * @param params
297318 return this . each ( function ( ) {
298319 var $target = $ ( this ) ;
299320 // If plug-in hasn't been applied before - initialize, otherwise - skip
300- if ( isPluginApplied ( this ) ) return ;
321+ if ( isPluginApplied ( this ) ) {
322+ updateMap ( getContextForElement ( this ) , $ ( this ) , options ) ;
323+ return ;
324+ }
301325 // Plug-in initialization is required
302326 // Defaults
303327 var settings = $ . extend ( { } , $ . fn . locationpicker . defaults , options ) ;
326350 } ) ;
327351 GmUtility . setPosition ( gmapContext , new google . maps . LatLng ( settings . location . latitude , settings . location . longitude ) , function ( context ) {
328352 updateInputValues ( settings . inputBinding , gmapContext ) ;
329- // Set up input bindings if needed
353+ // Set input bindings if needed
330354 setupInputListenersInput ( settings . inputBinding , gmapContext ) ;
331355 context . settings . oninitialized ( $target ) ;
332356 } ) ;
333357 } ) ;
334358 } ;
335359 $ . fn . locationpicker . defaults = {
336- location : { latitude : 40.7324319 , longitude : - 73.82480799999996 } ,
360+ location : { latitude : 40.7324319 , longitude : - 73.82480777777776 } ,
337361 locationName : "" ,
338362 radius : 500 ,
339363 zoom : 15 ,
350374 onchanged : function ( currentLocation , radius , isMarkerDropped ) { } ,
351375 onlocationnotfound : function ( locationName ) { } ,
352376 oninitialized : function ( component ) { }
353-
354377 }
355-
356- } ( jQuery ) ) ;
378+ } ( jQuery ) ) ;
0 commit comments