0
我是ember
和ember-leaflet.js
的新手。我试图通过ajax
调用json
文件将数据提供给我的车把模板和我的余烬小册子地图。用我目前的设置,数据到达我的把手模板就好了,但不会将坐标数据渲染到余烬传单图上。使用余烬模型从json解析余烬小叶坐标
我使用下面列出的两个示例作为我的指南,但由于缺乏有关ember的经验,因此碰壁了。任何人都可以指出我正确的方向吗?
Partial example of what I'm trying to accomplish
把手模板:
<script type="text/x-handlebars" data-template-name="application">
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
{{view App.MapView id="map"}}
<div id="blog">
<ul>
{{#each item in model}}
<li>{{item.headline}}</li>
{{/each}}
</ul>
</div>
</script>
恩贝尔:
App = Ember.Application.create();
App.Router.map(function() {
// put your routes here
});
App.IndexRoute = Ember.Route.extend({
model: function(){
return App.Item.all();
}
});
App.Item = Ember.Object.extend();
App.Item.reopenClass({
all: function() {
return $.getJSON("js/data/test_e.json").then(function(response) {
var items = [];
response.features.forEach(function (data) {
items.push(App.Item.create(data));
});
return items;
});
}
});
App.MarkerCollectionLayer =
EmberLeaflet.MarkerCollectionLayer.extend({
locationBinding: 'controller.item.center'});
App.MapView = EmberLeaflet.MapView.extend({
childLayers: [
EmberLeaflet.DefaultTileLayer,
App.MarkerCollectionLayer]
});
App.IndexController =
Ember.Controller.extend({});
JSON文件:
{
"features": [
{
"headline": "Docker, the Linux container runtime: now open-source",
"center" : [40.714, -74.000]
},
{
"headline": "What's Actually Wrong with Yahoo's Purchase of Summly",
"center" : [40.714, -73.989]
}
]
}
然而,这是考虑固定在EmberLeaflet结束一个伟大的项目 - 它应该在默认情况下正确处理纬度经度阵列。我已将它添加到我们的问题列表中! –