Skip to content Skip to sidebar Skip to footer

Location Picker Extract Values

I have a location picker in my website which works fine so far (code below). I have a JS function that extracts all interesting variables and places them in other elements. When a

Solution 1:

$("#locationpicker").locationpicker({
    location: {latitude: 52.518553, longitude: 13.404635},  
    radius: 200,
    inputBinding:
    {
        latitudeInput: $("#locationpicker_lat"),
        longitudeInput: $("#locationpicker_lon"),
        radiusInput: $("#locationpicker_radius"),
        locationNameInput: $("#locationpicker_address")
    },
    oninitialized: function (component) {
        /* component is $('#locationpicker') as far as I can tell
            ...but it doesn't look like you need it */
        setLocation('start');
    },
    enableAutocomplete: true
});

It seems like you've run into a callback issue. The plugin has an oninitialized callback which is fired after the plugin (and therefore the tags like locationpicker_lat) is initialized. Using it to determine when to execute setLocation should fix your issue. Don't forget to remove the call from the top-level of the script so it doesn't run twice.


Post a Comment for "Location Picker Extract Values"