Matt-Jensen / ember-cli-g-maps

Deprecated Google Maps Addon
http://matt-jensen.github.io/ember-cli-g-maps
MIT License
59 stars 31 forks source link

BUG: Zoom resets after drag #107

Closed bmfay closed 6 years ago

bmfay commented 6 years ago

Environment:

I am encountering an issue where, upon dragging the rendered map, the map resets to its default zoom after a few drags. Note that this is only happening when I am both passing in a default zoom level and passing in a dynamic lat/lng. If either of these is not the case, the problem is not present. Reproducing should be very simple. Template:

{{g-maps lat=lat lng=lng zoom=16}}

Controller (stripped everything out to ensure nothing else was going on)

import Ember from 'ember';

const { computed } = Ember;

export default Ember.Controller.extend({
  lat: computed(function() {
    return 22.45;
  }),

  lng: computed(function() {
    return -86.34534;
  }),
});

In our actual app, the lat lng is set dynamically from search, but I found even when I ripped out all of our code and just did the above, I still got the undesired zoom reset behavior. Again, if I don't pass in the zoom value here, there's no problem. If I pass in static coordinates, there's no problem. Please let me know if I can provide any other useful information.

Matt-Jensen commented 6 years ago

This is annoying behavior, without a doubt, however this component relies on 2 way bindings for zoom. In other words it expects you to manage the state of zoom. Passing an immutable value to zoom will have the result you described.

I recommend you set zoom on either a controller, parent component, or with something like ember let.