huafu / ember-google-map

An Ember addon to include a google-map Ember friendly component in your apps.
http://huafu.github.io/#/ember?name=ember-google-map
MIT License
87 stars 34 forks source link

Dynamically adding marker from controller action #65

Closed billybonks closed 9 years ago

billybonks commented 9 years ago

HI I am trying to add markers to the map when ever the user clicks

( i have tried adding a pojo and a Google map maker view) every time i add, i can see that the components makers.length is increasing but i cant see the markers on the map

controller

import Ember from 'ember';
import GoogleMapMarkerView from '../google-map/marker';

export default Ember.Controller.extend({
  battles:Ember.A([]),
  actions:{
    click:function(view,event){
      var gMarker = GoogleMapMarkerView.create({title: 'one', lat: event.latLng.A, lng: event.latLng.F, description: 'hello 1', isDraggable: true});
      var marker = {title: 'one', lat: event.latLng.A, lng: event.latLng.F, description: 'hello 1', isDraggable: true};
      this.get('battles').push(gMarker);
      console.log(view.get('markers.length'))
    }
  }
});

template

{{google-map ev_click="click" markers=battles}}
billybonks commented 9 years ago

fixed the issue, replaced push with pushObject