Logicify / jquery-locationpicker-plugin

JQuery Location Picker plugin
MIT License
389 stars 260 forks source link

Impossible to override values through mapOptions #95

Closed arogachev closed 8 years ago

arogachev commented 8 years ago

In new version 0.1.15 mapOptions setting is presented which is great, because mapTypeControl was disabled by default and earlier as a workaround I had to include my own two buttons and programmatically toggle map type.

Now I tried to set mapTypeControl to true (because default Google Maps controls are enough in my case):

mapOptions: {
    mapTypeControl: true
},

And as a result, this option was not overridden and was left with false value.

After some debugging I found the reason is a wrong way of using extend:

var gmapContext = new GMapContext(this, $.extend({}, settings.mapOptions, {
    zoom: settings.zoom,
    center: new google.maps.LatLng(settings.location.latitude, settings.location.longitude),
    mapTypeId: settings.mapTypeId,
    mapTypeControl: false,
    styles: settings.styles,
    disableDoubleClickZoom: false,
    scrollwheel: settings.scrollwheel,
    streetViewControl: false,
    radius: settings.radius,
    locationName: settings.locationName,
    settings: settings,
    autocompleteOptions : settings.autocompleteOptions,
    addressFormat: settings.addressFormat,
    draggable: settings.draggable,
    markerIcon: settings.markerIcon,
    markerDraggable: settings.markerDraggable,
    markerVisible: settings.markerVisible
}));

The order of arguments is wrong. Must be:

var gmapContext = new GMapContext(this, $.extend({}, {
    zoom: settings.zoom,
    center: new google.maps.LatLng(settings.location.latitude, settings.location.longitude),
    mapTypeId: settings.mapTypeId,
    mapTypeControl: false,
    styles: settings.styles,
    disableDoubleClickZoom: false,
    scrollwheel: settings.scrollwheel,
    streetViewControl: false,
    radius: settings.radius,
    locationName: settings.locationName,
    settings: settings,
    autocompleteOptions : settings.autocompleteOptions,
    addressFormat: settings.addressFormat,
    draggable: settings.draggable,
    markerIcon: settings.markerIcon,
    markerDraggable: settings.markerDraggable,
    markerVisible: settings.markerVisible
}, settings.mapOptions));

It was caused by commit https://github.com/Logicify/jquery-locationpicker-plugin/commit/3403d4360009c0e930cfb234bfeb875efdd10066.

Note that initially in #36 it was written correctly.

I'll send PR soon.

It will be great to release new version because this is definerely a bug.

arogachev commented 8 years ago

Fixed in https://github.com/Logicify/jquery-locationpicker-plugin/commit/a8a5c5caba21a3db2b2203475a3ba4e24565eec1.

arogachev commented 8 years ago

Note that at the moment of writing this you need to use jquery-locationpicker-plugin/src/locationpicker.jquery.js file only because changes were applied only there.

Sumragen commented 8 years ago

@arogachev you are fully right. With next release this changes will be applied in 'dist' folder. Thank you.