219
219
} , 300 ) ;
220
220
}
221
221
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
+ }
222
243
/**
223
- * Initialization :
244
+ * Initializeialization :
224
245
* $("#myMap").locationpicker(options);
225
246
* @param options
226
247
* @param params
297
318
return this . each ( function ( ) {
298
319
var $target = $ ( this ) ;
299
320
// 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
+ }
301
325
// Plug-in initialization is required
302
326
// Defaults
303
327
var settings = $ . extend ( { } , $ . fn . locationpicker . defaults , options ) ;
326
350
} ) ;
327
351
GmUtility . setPosition ( gmapContext , new google . maps . LatLng ( settings . location . latitude , settings . location . longitude ) , function ( context ) {
328
352
updateInputValues ( settings . inputBinding , gmapContext ) ;
329
- // Set up input bindings if needed
353
+ // Set input bindings if needed
330
354
setupInputListenersInput ( settings . inputBinding , gmapContext ) ;
331
355
context . settings . oninitialized ( $target ) ;
332
356
} ) ;
333
357
} ) ;
334
358
} ;
335
359
$ . fn . locationpicker . defaults = {
336
- location : { latitude : 40.7324319 , longitude : - 73.82480799999996 } ,
360
+ location : { latitude : 40.7324319 , longitude : - 73.82480777777776 } ,
337
361
locationName : "" ,
338
362
radius : 500 ,
339
363
zoom : 15 ,
350
374
onchanged : function ( currentLocation , radius , isMarkerDropped ) { } ,
351
375
onlocationnotfound : function ( locationName ) { } ,
352
376
oninitialized : function ( component ) { }
353
-
354
377
}
355
-
356
- } ( jQuery ) ) ;
378
+ } ( jQuery ) ) ;
0 commit comments