0

我想以包含位置的表单输入位置,然后单击提交按钮,该位置应显示在谷歌地图中。谷歌地图应该显示在下一页,我想用图标显示在医院附近。

我试过了,但我没有。

应用程序/模板/newcase.hbs

<form class="form-horizontal">

          <div class="form-group">
            <label class="col-md-4 control-label"     for="textInput2">Location</label>
            <div class="col-md-8">
              {{input type="text" class="form-control" value=location}}
            </div>
          </div>

          <div class="form-group">
 <label class="col-md-4 control-label" for="textInput2"></label>
   <div class="col-md-8">
  <button {{action 'addCase' model.id}} type="button" class="btn btn-primary">Submit</button>
  <button type="button" class="btn btn-default">Cancel</button>
</div>

应用程序/路由/newcase.js

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

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

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

应用程序/模型/case.js

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

应用程序/模板/组件/new-case.js

import Ember from 'ember';
export default Ember.Component.extend({
  actions: {
        submit() {
        if (Ember.isPresent(this.get('case.location'))) { 
        this.set('mapIsShown', true);
            }
  },
 } 
});

我将app/template/newcase.hbs 更改app/template/component/new-case.hbs

应用程序/模板/index.hbs

{{新案例}}

请告诉我如何显示位置和附近的医院以及如何添加每家医院的纬度,纬度

4

0 回答 0