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

Need to be able to add markers post-creation

tigerhawkvok opened this issue · comments

So, for example, say I have a map that I'm going to asynchronously fetch the points for the markers. For the sake of UX, I want to show a basic map first of the region-of interest. Then, say my geo data is stored on CartoDB and I fetch it asynchronously, and get rows back.

Doing this:

    for k, row of rows
      geoJson = JSON.parse row.st_asgeojson
      lat = geoJson.coordinates[0]
      lng = geoJson.coordinates[1]
      # Fill the points as markers
      marker = """
      <google-map-marker latitude="#{lat}" longitude="#{lng}">
        <p>
          Some Infowindow Content
        </p>
      </google-map-marker>
      """
      $("#myEarlierMap").append marker

the element doesn't recognize the new markers. I also tried calling $$("#myEarlierMap")[0].resize(), but this still didn't show the markers (and calling $$("#myEarlierMap")[0].markers returns []).

marker children should be observed: https://github.com/GoogleWebComponents/google-map/blob/master/google-map.html#L463

can you put together a jsbin that repos the issue? here's a starter: http://jsbin.com/ketujo/edit?html,output

Closing for inactivity. Fee free to reopen.

Whoops, life got busy and ate me.

Here's a jsfiddle:

https://jsfiddle.net/tigerhawkvok/ofu7dfnm/8/

Loads a cluster of points in Berkeley, the dropper appends a marker to the map near Death Valley -- except it doesn't.