使用Meteor

时间:2015-08-21 03:08:00

标签: google-maps meteor leaflet

我试图制作一张地图,传单或谷歌地图,根据包含Meteor地址的循环创建标记。我一直在查看一些软件包,但对如何在参数中使用循环感到困惑。以下是代码,任何帮助将不胜感激!

系列:

Homes = new Mongo.Collection('daycares');

Homes.attachSchema(new SimpleSchema({
  name: {
    type: String,
    label: "Daycare Name",
    max: 100
  },
  address: {
    type: String,
    label: "Address",
    max: 100
  },
  yib: {
    type: Number,
    label: "Years in Business"
  },
  contactname: {
  type: String,
  label: "Contact Name",
  max: 100
  },
  phone: {
    type: Number,
    label: "Phone Number"
  },
  licensed: {
    type: Boolean,
    label: "Licensed?"
  },
  description: {
    type: String,
    label: "Description"
  },
    userId: {
    type: String,
    optional: true,
    autoValue: function () {
      return this.userId;
    }
  }
}));


if (Meteor.isServer) {
  Homes.allow({
    insert: function (userId, doc) {
      return true;
    },

    update: function (userId, doc, fieldNames, modifier) {
      return true;
    },

    remove: function (userId, doc) {
      return true;
    }
  });

  // Homes.deny({
  //   insert: function (userId, doc) {
  //     return true;
  //   },

  //   update: function (userId, doc, fieldNames, modifier) {
  //     return true;
  //   },

  //   remove: function (userId, doc) {
  //     return true;
  //   }
  // });
}

HTML:

<template name="ListHomes">
  <h1>Home List</h1>
  <table class="table table-hover">
    <thead>
      <tr>
        <th>Name</th>
        <th>Address</th>
        <th>Years in Business</th>
        <th>Contact Name</th>
        <th>Email</th>
        <th>Phone Number</th>
        <th>Licensed</th>
        <th>Description</th>
        <th>Userid</th>
        <th>Edit</th>
      </tr>
    </thead>
    <tbody>
      {{#each homes}}
        <tr>
          <td>{{name}}</td>
          <td>{{address}}</td>
          <td>{{yib}}</td>
          <td>{{contactname}}</td>
          <td>{{userEmail userId}}</td>
          <td>{{phone}}</td>
          <td>{{licensed}}</td>
          <td>{{description}}</td>
          <td>{{userId}}</td>
          <td>{{#linkTo route='editDaycare'}}<span class="glyphicon glyphicon-edit"></span>{{/linkTo}}</td>
        </tr>
      {{/each}}
    </tbody>
  </table></template>

JS:

/*****************************************************************************/
    /* ListHomes: Event Handlers */
    /*****************************************************************************/
    Template.ListHomes.events({
    });

    /*****************************************************************************/
    /* ListHomes: Helpers */
    /*****************************************************************************/
    Template.ListHomes.helpers({
        homes: function() {
            return Homes.find();
        }

    });

    UI.registerHelper('userEmail', function(context, options) {
      if(context)
        return Meteor.users.findOne(context).emails[0].address;
    });

    /*****************************************************************************/
    /* ListHomes: Lifecycle Hooks */
    /*****************************************************************************/
    Template.ListHomes.created = function () {
    };

    Template.ListHomes.rendered = function () {
    };

    Template.ListHomes.destroyed = function () {
    };

0 个答案:

没有答案