1

嗨伙计们,我正在研究meteorjs,但在firefox上看东西时遇到了一些问题。在谷歌浏览器上,一切都很好,我可以看到一切没有错误。

我的代码是:

//->服务器/server.js

Meteor.publish('places', function () {
return Places.find();
});

/-->model.js Places = new Meteor.Collection('placesNew');

Places.allow({
  insert: function(){
    return false;
  },
  update: function(){
    return false;
  },
  remove: function(){
    return false;
  }
});

Meteor.methods({
  createPlace: function(options){
    check(options, {name: NonEmptyString, latitude: NonEmptyString , longitude:NonEmptyString , color: NonEmptyString});
    return Places.insert({name:options.name, latitude: options.latitude, longitude: options.longitude, color: options.color});
  },

  removePlace: function(options){
    return Places.remove(options.id);
  }
});

var NonEmptyString = Match.Where(function (x) {
  check(x, String);
  return x.length !== 0;
});

/-->服务.js

var map;
renderize_map = function (places){
  var mapOptions = {
        center: new google.maps.LatLng(47.36865 , 8.539183),
        zoom: 3,
        mapTypeId: google.maps.MapTypeId.ROADMAP

      };
     map= new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
      places.forEach(function (place) {
        var pinColor = place.color.replace("#","");
        var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + pinColor,
        new google.maps.Size(21, 34),
        new google.maps.Point(0,0),
        new google.maps.Point(10, 34));

      var marker = new google.maps.Marker({
                  position: new google.maps.LatLng(place.latitude, place.longitude),
                  title: place.name,
                  icon: pinImage,
                  map: map
              });
    });
}

/-->客户端/places_list.js

Meteor.subscribe('places');

Template.places_list.places = function () {
  return Places.find({},{sort:{name: -1}});

}

Template.places_list.events({
  'click #add':function() {
      options ={};
      options.name = document.getElementById('name').value;
      options.latitude = document.getElementById('latitude').value;
      options.longitude = document.getElementById('longitude').value;
      options.color = document.getElementById('color').value;
      Meteor.call('createPlace',options, function(error,place){
        if(error){
          console.log("Não Foi possível inserir");
        }

      });
      renderize_map(Places.find({},{sort:{name: 1}}));
  },
    'click .plc_remove': function(obj){
      options={};
      options.id=obj.toElement.attributes['data-ref'].value;

      Meteor.call('removePlace',options, function(error,place){
        if(error){
          console.log("Não Foi possível inserir");
        }

      });      
      renderize_map(Places.find({},{sort:{name: 1}}));
    }

});

Template.maps.rendered = function() {
    renderize_map(Places.find({},{sort:{name: 1}}));
  }

/-->客户端/places_list.css

/* CSS declarations go here */
#map-canvas{
  width:  500px;
  height: 500px;
}

/-->客户端/places_list.html

<head>
  <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">    </script>  
</head>
<body>
  <header>
    <h1>TableList</h1>
    {{> places_list}}
    {{> maps}}
  </header>
</body>

<template name="places_list">
  <div class"place-list-form">
    <input type="text" placeholder="Insert a place here" value="{{name}}" id="name"/><br>
    <input type="text" placeholder="Insert a Latitude here" value="{{latitude}}" id="latitude"/><br>
    <input type="text" placeholder="Insert a Longitude here " value="{{longitude}}" id="longitude"/><br>
    <input type="text" placeholder="Insert a Color here " value="{{longitude}}" id="color"/>  
    <button id="add">Add point</button>

  </div>  
  <div class"place-list-container">
    <ul>
      {{#each places}}
      <li> {{ name}} | <a class="plc_remove" data-ref="{{_id}}" href="#">x</a> | </li>
      {{/each}}
    </ul>

  </div>

</template>

<template name="maps">
  <div id="map-canvas"></div>

</template>

错误是:

SyntaxError: missing } after function body
http://localhost:3000/packages/livedata.js?a3d111217f95d5af907302198a85413d1acbaf05
Line 1766

TypeError: Package.livedata is undefined
http://localhost:3000/packages/mongo-livedata.js?a3509c5f9f4ed6ded19eaac97c69c2a91d81df81
Line 28

TypeError: Package.livedata is undefined
http://localhost:3000/packages/global-imports.js?fbb54e05f02190869755c48bbc5e3bd9f17811b4
Line 7

ReferenceError: Template is not defined
http://localhost:3000/client/template.places_list.js?ee7af8e7be9b55207b7bef609fa51cb0e5f513a9
Line 1

TypeError: Meteor.subscribe is not a function
http://localhost:3000/client/places_list.js?6a2a131bfee6da3c6e08cee25711a90317cb4a4e
Line 1

TypeError: Meteor.Collection is not a constructor
http://localhost:3000/model.js?9eed9b90a309156348195efef61705bab5494768
Line 1


ReferenceError: Spark is not defined
http://localhost:3000/client/template.places_list.js?ee7af8e7be9b55207b7bef609fa51cb0e5f513a9
Line 1

谁能帮我?

谢谢!

4

1 回答 1

0

我只是将您的所有代码复制并粘贴到一个项目中,它适用于 Firefox(OSX 上的版本 19.0.2)和 Chrome。或者至少它会加载所有内容,我可以添加一个在其他浏览器中作为名称可见的位置,它没有向地图添加图钉。

您得到的错误是非常基本的错误,表明一些基本的内置包没有正确加载。我不明白为什么这只会在一个浏览器中成为问题。如果您在浏览器中查看源代码,Chrome 和 Firefox 中的软件包列表是否相同?

作为建议,我会尝试编辑包文件(项目根目录中的.meteor/packages)。尝试删除所有明显会导致应用程序停止工作的包并再次添加默认包:

  • 标准应用程序包
  • 自动发布
  • 不安全
  • 保留输入

除此之外,其他流星应用程序在 Firefox 中运行正常吗?如果不看看你有什么附加组件和设置。如果只是这个应用程序,其他人可以让它在 Firefox 中运行,那么我能想到的就是重新制作项目,复制和粘贴你的文件。

于 2013-10-04T01:14:33.297 回答