Hey Fredrik,
You need to replace
this.set('zoom', this.map.zoom);
with
this.bindTo('zoom', this.map);
The first method just sets the value of zoom on the MarkerWidget with the
Map's zoom value, and if any other objects are bound to the MarkerWidget's
zoom property then their zoom_changed function will be called.
Because the MarkerWidget is interested in when the Map's zoom values changes
then the MarkerWidget needs to bindTo the Map's zoom property.
Hope this makes sense and helps :)
- Luke
On Thu, Apr 22, 2010 at 5:46 AM, fredrik <[email protected]>wrote:
> Hi,
>
> I'm trying to use the MVC objects in google maps version 3. What I
> can't seem to figure out is why my zoom_changed method is only invoked
> once. When I first load the map the zoom_changed method is invoked.
> But not when I zoom on the map.
>
> function MarkerWidget (options) {
> this.setValues(options);
> this.set('zoom', this.map.zoom);
>
> var marker = new google.maps.Marker({
> icon : this.icon,
> mouseOverIcon : this.mouseOverIcon,
> orgIcon : this.orgIcon
> });
>
> marker.bindTo('map', this);
> marker.bindTo('position', this);
>
> google.maps.event.addListener(marker, 'mouseover',
> this.onmouseover);
> google.maps.event.addListener(marker, 'mouseout',
> this.onmouseout);
>
> }
>
> MarkerWidget.prototype = new google.maps.MVCObject();
> MarkerWidget.prototype.zoom_changed = function () {
> $.log(this, new Date());
> }
> Shouldn't the map object fire the zoom event and notify all object's
> that has "this.set('zoom', this.map.zoom)" ?
>
> ..fredrik
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.