116
116
117
117
function setupInputListenersInput ( inputBinding , gmapContext ) {
118
118
if ( inputBinding ) {
119
- inputBinding . radiusInput . on ( "change" , function ( ) {
120
- gmapContext . radius = $ ( this ) . val ( ) ;
121
- GmUtility . setPosition ( gmapContext , gmapContext . location ) ;
122
- } ) ;
119
+ if ( inputBinding . radiusInput ) {
120
+ inputBinding . radiusInput . on ( "change" , function ( ) {
121
+ gmapContext . radius = $ ( this ) . val ( ) ;
122
+ GmUtility . setPosition ( gmapContext , gmapContext . location ) ;
123
+ } ) ;
124
+ }
123
125
if ( inputBinding . locationNameInput && gmapContext . settings . enableAutocomplete ) {
124
126
gmapContext . autocomplete = new google . maps . places . Autocomplete ( inputBinding . locationNameInput . get ( 0 ) ) ;
125
127
google . maps . event . addListener ( gmapContext . autocomplete , 'place_changed' , function ( ) {
195
197
if ( isPluginApplied ( this ) ) return ;
196
198
// Plug-in initialization is required
197
199
// Defaults
198
- var settings = $ . extend ( $ . fn . locationpicker . defaults , options ) ;
200
+ var settings = $ . extend ( { } , $ . fn . locationpicker . defaults , options ) ;
199
201
// Initialize
200
202
var gmapContext = new GMapContext ( this , {
201
203
zoom : settings . zoom ,
209
211
locationName : settings . locationName ,
210
212
settings : settings
211
213
} ) ;
212
- $ ( this ) . data ( "locationpicker" , gmapContext ) ;
214
+ $target . data ( "locationpicker" , gmapContext ) ;
213
215
// Subscribe GMap events
214
216
google . maps . event . addListener ( gmapContext . marker , "dragend" , function ( event ) {
215
- GmUtility . setPosition ( gmapContext , gmapContext . marker . position , function ( ) {
217
+ GmUtility . setPosition ( gmapContext , gmapContext . marker . position , function ( context ) {
216
218
var currentLocation = GmUtility . locationFromLatLng ( gmapContext . location ) ;
217
- settings . onchanged ( currentLocation , gmapContext . radius , true ) ;
218
- updateInputValues ( settings . inputBinding , gmapContext ) ;
219
+ context . settings . onchanged ( currentLocation , context . radius , true ) ;
220
+ updateInputValues ( gmapContext . settings . inputBinding , gmapContext ) ;
219
221
} ) ;
220
222
} ) ;
221
- GmUtility . setPosition ( gmapContext , new google . maps . LatLng ( settings . location . latitude , settings . location . longitude ) , function ( ) {
223
+ GmUtility . setPosition ( gmapContext , new google . maps . LatLng ( settings . location . latitude , settings . location . longitude ) , function ( context ) {
222
224
updateInputValues ( settings . inputBinding , gmapContext ) ;
223
- settings . oninitialized ( $target ) ;
225
+ context . settings . oninitialized ( $target ) ;
224
226
} ) ;
225
227
// Set up input bindings if needed
226
228
setupInputListenersInput ( settings . inputBinding , gmapContext ) ;
246
248
247
249
}
248
250
249
- } ( jQuery ) ) ;
251
+ } ( jQuery ) ) ;
0 commit comments