如何获取数据

时间:2016-06-30 07:58:51

标签: ember.js ember-components ember-controllers

请告诉我如何从firebase中获取数据

应用程序/模板/ gmap.hbs

  {{#leaflet-map lat=lat lng=lng zoom=zoom}}

  {{tile-layer url="http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png"}}

 {{#each model as |c|}}
 {{#layers.marker lat=c.latitude lng=c.longitude draggable=true}}
 {{/layers.marker}}
 {{/each}}

 {{/leaflet-map}}

应用程序/控制器/ newcase.js

 import Ember from 'ember';
 export default Ember.Controller.extend({
 actions:{
 addCase: function() {
 var hname = this.get('hname');
 var location = this.get('location');
 var latitude = this.get ('latitude');
 var longitude = this.get('longitude');
 var newCase = this.store.createRecord('case', {
 hname : hname,
 location : location,
 latitude : latitude,
 longitude : longitude
 });
 newCase.save();
 this.setProperties({
 hname: ' ',
 location: ' ',
 latitude: ' ',
 longitude: ' '
 });
 }
}
});

应用程序/控制器/ gmap.js

  import  Ember from 'ember';
  export default Ember.Controller.extend ({
 });

app/model/case.js

import Model from 'ember-data/model';
import attr from 'ember-data/attr';
 export default Model.extend({
 hname : attr('string'),
 location: attr('string'),
 latitude: attr('number'),
 longitude: attr('number')
 });

app/route/newcase.js

import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.get('store').findAll('case');
 }
});

firebase数据enter image description here

我想在地图中显示该位置,lat和lng我没有得到如何显示请告诉我如何为此编写代码。

1 个答案:

答案 0 :(得分:0)

如果你查看ember-leaflet v2的文档,标记图层组件可能是你的问题。

{{#leaflet-map lat=lat lng=lng zoom=zoom}}    

  {{tile-layer url="http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png"}}    

  {{#marker-layer location=emberConfLocation}}
    <h3>The Oregon Convention Center</h3>
    777 NE Martin Luther King Jr Blvd<br>
    Portland, OR 97232
  {{/marker-layer}}    

  {{#marker-layer location=hotel}}
    <h3>Hotel</h3>
  {{/marker-layer}}    

{{/leaflet-map}}
我猜

{{layers.marker}}无效