GoogleWebComponents / google-map

Google Maps web components

Home Page:https://elements.polymer-project.org/elements/google-map

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google map marker: doesn't update InfoWindow when stamped using map attribute binding

tst-dhudlow opened this issue · comments

The example code for displaying google search results is this:

<template is="dom-bind">
  <google-map-search map="[[map]]" query="Pizza" results="{{results}}">
  </google-map-search>
  <google-map map="{{map}}" latitude="37.779"
              longitude="-122.3892">
    <template is="dom-repeat" items="{{results}}" as="marker">
      <google-map-marker latitude="{{marker.latitude}}"
                         longitude="{{marker.longitude}}">
        <h2>{{marker.name}}</h2>
        <span>{{marker.formatted_address}}</span>
      </google-map-marker>
    </template>
  </google-map>
</template>

This works, but if you want to use the map binding outside the google-map element instead like this:

<template is="dom-bind">

  <google-map-search map="[[map]]" query="Pizza" results="{{results}}">
  </google-map-search>

  <template is="dom-repeat" items="{{results}}" as="marker">
    <google-map-marker map="{{map}}"
                       latitude="{{marker.latitude}}"
                       longitude="{{marker.longitude}}">
      <h2>{{marker.name}}</h2>
      <span>{{marker.formatted_address}}</span>
    </google-map-marker>
  </template>

  <google-map map="{{map}}" latitude="37.779"
              longitude="-122.3892">
  </google-map>
</template>

The InfoWindow doesn't have the resolved bindings. Instead, it has empty h2 and span tags. This has to due with the order of operations. One-line PR coming soon that fixes it. May not be the right solution, though.

Almost certainly related to #280