AugustMiller / kirby-place-field

Deprecated! A simple Google Maps field for Kirby CMS. Please use my Map Field plugin, instead:
https://github.com/AugustMiller/kirby-map-field
21 stars 3 forks source link

Adding the zoom to the stored data #9

Open janoelze opened 8 years ago

janoelze commented 8 years ago

Hey, thanks for your work on this plugin. I'm trying to squeeze the zoom into the data that gets serialized to the content-file, but i can't get it to work.

These are the fields I'm currently writing to the returned field object:

store: function () {
      //this.map_canvas = this.container.find('.field-google-map-ui');
      this.field.val(JSON.stringify({
        address: this.location_fields.address.val(),
        lat: parseFloat(this.location_fields.lat.val()),
        lng: parseFloat(this.location_fields.lng.val()),
        zoom: parseFloat(this.map.getZoom())
      }));
    }

When i call this.map.getZoom() it always returns 9, regardless of the actual zoom. Is there a function that gets executed before store function that is somehow resetting the map zoom? The 9 seems to originate from this data-zoom attribute.

AugustMiller commented 8 years ago

I don't see anything wrong with this, immediately… Though, you probably don't need to parseFloat for the return value of getZoom()— the API should return an integer already.

Do you mind verifying that the result of this.map.getZoom() changes when you change either the global setting (c::set('place.defaults.zoom', x)) or your blueprint setting?

fields:
  location:
    label: Location
    type: place
    center:
      lat: 45.5230622
      lng: -122.67648159999999
      zoom: 2 # Anything but 9 :)

Other than that, I can't really think of why Google wouldn't be updating the zoom level to match what you see!