Meteor JS mdg:geolocation + dburles/meteor-google-maps, Google 地方库错误
Meteor JS mdg:geolocation + dburles/meteor-google-maps, Google Places library error
我正在使用 mdg:geolocation + dburles/meteor-google-maps 加载 Google 地图并显示本地结果。除了 Google Places 库外,地图工作正常,地理定位也工作正常。
我收到以下错误 "Uncaught TypeError: this.j.getElementsByTagName is not a function"。我可以获得 Google 个在 Meteor 之外工作的地方,甚至没有两个包集成。
大约 3 个月前,另一个用户已经问过这个问题。但看起来线程已经死了。这是我在控制 maps/geolocation
的 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');
});
});
});
我正在将地图传递给 new google.maps.places.PlacesService(map) 而我需要传递 map.instance new google.maps.places.PlacesService(map.instance)
我正在使用 mdg:geolocation + dburles/meteor-google-maps 加载 Google 地图并显示本地结果。除了 Google Places 库外,地图工作正常,地理定位也工作正常。
我收到以下错误 "Uncaught TypeError: this.j.getElementsByTagName is not a function"。我可以获得 Google 个在 Meteor 之外工作的地方,甚至没有两个包集成。
大约 3 个月前,另一个用户已经问过这个问题。但看起来线程已经死了。这是我在控制 maps/geolocation
的 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');
});
});
});
我正在将地图传递给 new google.maps.places.PlacesService(map) 而我需要传递 map.instance new google.maps.places.PlacesService(map.instance)