Google maps api 3 MeteorJS无限页面刷新

Google maps api 3 MeteorJS无限页面刷新,google-maps-api-3,meteor,google-geolocation,Google Maps Api 3,Meteor,Google Geolocation,我正在开发一个小应用程序,它使用谷歌地图API(加上地理定位API)在谷歌地图上绘制点 这是我的密码: map.js: Template.gmap.rendered = function() { if(! Session.get('map')) gmaps.initialize(); gmaps.mapCities(); } Template.gmap.destroyed = function() { Session.set('map', false);

我正在开发一个小应用程序,它使用谷歌地图API(加上地理定位API)在谷歌地图上绘制点

这是我的密码:

map.js:

Template.gmap.rendered = function() {
    if(! Session.get('map'))
        gmaps.initialize();

  gmaps.mapCities();
}

Template.gmap.destroyed = function() {
    Session.set('map', false);
}
gmap.js:

gmaps = {
    map: null,

    initialize: function() {
        console.log("[+] Initializing Google Maps...");

        var mapOptions = {
            zoom: 4,
            center: new google.maps.LatLng(38.7, -95),
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            mapTypeControl: false,
            streetViewControl: false,
            draggable: false,
            zoomControl: true,
            zoomControlOptions: {
                style: google.maps.ZoomControlStyle.SMALL
            }
        };

        this.map = new google.maps.Map(
            document.getElementById('map-canvas'),
            mapOptions
        );

        this.map.setOptions({styles: window.mapStyles});

        Session.set('mapLoaded', true);
    },

    mapCities: function(){
      var t = this;
      console.log("[+] city mapping begins");
      $.each(cities, function(index, c){
        city_name = c.split(", ").join("+");
        city = Cities.findOne({city_name: city_name});

        if(!city) {
          console.log("NO CITY FOUND. SAVING DA CITY: " + city_name);

          Meteor.call("retrieveLatLng", city_name, function(error, json){
            results = json.data.results[0];
            location = results.geometry.location;
            id = createCity(city_name, location);
            city = Cities.findOne({_id: id});
            t.addMarker(city, city.id);
          });
        } else {
          t.addMarker(city, city.id);
        }

      })
    },

    _parseGeoLocation: function(job) {
        var location, t = this;

        Meteor.call("retrieveLatLng", job.address, function(error, json){
            results = json.data.results[0];
            location = results.geometry.location;
            t.addMarker(location, job.id, true);
        });
    },

    addMarker: function(marker, id, update) {
        var gLatLng = new google.maps.LatLng(marker.lat, marker.lng);

        if(typeof(update) !== "undefined" && update) {
          Jobs.update(
            {_id: id},
            {$set: {lat: location.lat, lng: location.lng}}
          );
        }

        var gMarker = new google.maps.Marker({
            position: gLatLng,
            map: this.map,
            title: marker.title,
            icon: 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png'
        });

        return gMarker;
    },

    jobExists: function(jvid) {
        return Jobs.findOne({jvid: id});
    }
}
main.js:

if (Meteor.isServer) {

  Meteor.methods({
    retrieveJobs: function(url){
      this.unblock();
      var url = url + "&cn=100";
      return HTTP.get("http://api.us.jobs/?key=API_KEY_HERE&" + url);
    },
    retrieveLatLng: function(address){
      this.unblock();
      return HTTP.get("https://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&components=country:US&sensor=false&key=API_KEY_HERE");
    }
  });
}

当我加载页面时,页面大约每2秒自动刷新一次,url如下所示:
http://localhost:3000/[对象%20对象]
。。。不确定我做错了什么

您正在设置变量
location
,即
window.location
。因此,您可以告诉浏览器替换其位置/重定向到位置对象。(因此,您将
[object object]
视为重定向到的位置)


如果您为
位置
变量使用不同的名称,例如
var location\u var
,则应该可以。

您正在设置变量
位置
,即
窗口.位置
。因此,您可以告诉浏览器替换其位置/重定向到位置对象。(因此,您将
[object object]
视为重定向到的位置)

如果您为
位置
变量使用不同的名称,例如
var location\u var
,则应该可以