Using google-map v1.1.10 against git://github.com/GoogleWebComponents/google-map.git#*
I build up my markers like so:
<template>
<site-data sites="{{sites}}"> </site-data>
<google-map fit-to-markers >
<template is="dom-repeat" items="{{sites}}">
<template is="dom-repeat" items="{{item}}">
<google-map-marker latitude={{item.latitude}}
longitude={{item.longitude}}
title="{{item.project_name}}"
>
<h1>{{item.project_name}}</h1>
<p style="margin: 0;">Location: <b>{{item.town}}, {{item.country}}</b></p>
<p style="margin: 0;">Tech Description: <b>{{item.tech_desc}}</b></p>
</google-map-marker>
</template>
</template>
</google-map>
Upon initial loading of the webapp, things work really well. I can click on a marker and the infowindow shows the content. However, if I change any values in my sites array, I seem to lose the infowindow and/or the click event. I have to refresh the browser to get back to my initial condition (click to show infowindow).
Also, The marker locations will update perfectly if I change lat/long and hovering shows tooltip aka. title, appropriately as well.
I've added a click event which calls a console.log to the click event. It works well until a value is changed in the {{sites}} binding, so it seem I am losing click events when the google-map updates itself?
There are no scripts in this element.
If I can provide more information, please let me know.
Thanks in Advance, Scott
It looks like there are some problems with GoogleMapMarker. I have some hacks you can try, but you should make an issue ticket so somebody can take a deeper look.
One problem is that the MutationObserver that updates MapMarker is not observing
characterData
, so it doesn't fire when MapMarker's simple text content changes.Another problem is that the
attach
/detach
implementations don't seem to be complementary. For example,detach
removes the MutationObserver andattach
never puts it back.Lastly, there are cases when the
info
window become disconnected from the MapMarker.Here is a JSBin where there are three kinds of mutations of a GoogleMapMarker setup as you described: http://jsbin.com/hobixi/edit?html.
Adding a new map marker seems to work just fine.
Modifying content of an existing marker fails because of the MutationObserver problem I described. I fixed that by monkey patching GoogleMapMarker's
_contentChanged
method like so:Example:
attached
anddetached
like so:Example:
You didn't specify the nature of the changes you are triggering. The
clicking doesn't show the info window
problem seems to be what happens when the Marker and the Info become discombobulated, maybe there is anattach/detach
happening.Well played baiting me to look into this. :)