2016-07-04 1 views
0

Googleマップを読み込んでローカル結果を表示するには、mdg:geolocation + dburles/meteor-google-mapsを使用しています。 Googleプレイスライブラリを除き、地図は正常に機能し、ジオロケーションは正常に機能します。Meteor JS mdg:geolocation + dburles/meteor-google-maps、Googleプレイスライブラリのエラー

次のエラーが表示されます「未知の型エラー:this.j.getElementsByTagNameが関数ではありません」 GoogleプレイスをMeteorの外で、また2つのパッケージ統合なしでも利用できるようになりました。

この質問は、約3ヶ月前までに他のユーザーから聞かれました。しかし、スレッドが死んだように見えます。ここのjsファイル内の私の次のコードマップを制御/ジオロケーション

Meteor.startup(function() { 
    GoogleMaps.load({ 
    v : '3', 
    key: 'mYKeyinHereBLAHABLAHBLAH', 
    libraries: 'places' 
    }); 
}); 

Template.map.helpers({ 
    //get current lat & lng and create map 
    geolocationError: function() { 
     let error = Geolocation.error(); 
     return error && error.message; 
    }, 
    mapOptions: function() { 
     let latLng = Geolocation.latLng(); 
     // Initialize the map once we have the latLng. 
     if (GoogleMaps.loaded() && latLng) { 
      return { 
       center: new google.maps.LatLng(latLng.lat, latLng.lng), 
       zoom: 15 
      }; 
     } 
    } 
}); 

Template.map.onRendered(function() { 
    let self = this; 

    GoogleMaps.ready('map', function(map) { 
     let latLng = Geolocation.latLng(); 

     let marker; 
     self.autorun(function() { 
      //set user location 
      let marker = new google.maps.Marker({ 
       position: new google.maps.LatLng(latLng.lat, latLng.lng), 
       map: map.instance 
      }); 
      marker.setPosition(latLng); 
      map.instance.setCenter(marker.getPosition()); 
      map.instance.setZoom(15); 

      //google places 
      let Places = function(locationType){ 
       this.locationType = locationType; 

       let place = new google.maps.places.PlacesService(map); 
       place.nearbySearch({ 
        location: latLng, 
        radius: 16100, //10 mile radius 
        keyword: [locationType] 
       }, getPlace); 

       function getPlace(results, status) { 
        if (status === google.maps.places.PlacesServiceStatus.OK) { 
         for (let i = 0; i < results.length; i++) { 
          console.log(results[i]); 
          createPlaceMarkers(results[i]); 
         } 
        } 
       } 

       function createPlaceMarkers(place) { 
        let placeLocation = place.geometry.location, 
         placeMaker  = new google.maps.Marker({ 
          map: map, 
          position: place.geometry.location, 
          draggable:false, 
          zIndex: 9997 
         }); 
       } 
      } 

      let bars = new Places('Bar'), 
       club = new Places('Night Club'); 

     }); 
    }); 
}); 

答えて

0

ではなく、私がmap.instance を渡すために必要なときに、私は新しいgoogle.maps.places.PlacesService(マップ)にマップを渡したです新しいgoogle.maps.places.PlacesService(map.instance)

関連する問題