EDIT: Solved, it was pretty stupid, I needed to use map.instance.setCenter, however I'd like a confirmation that this is the "way to go" before closing if possible :) Thanks a lot and have great day everyone !
Hi,
I've been encountering an issue with the "map" in the callback function on .ready().
After implementing a reactive map as seen here, I can't use the "map" argument at all..
This code doesn't work:
GoogleMaps.ready('exampleMap', function(map) {
// Add a marker to the map once it's ready
Tracker.autorun(function() {
if(Session.get('lat') && Session.get('lng')) {
map.setCenter({ lat: Session.get('lat'), lng: Session.get('lng') });
}
});
});
It tells me that
TypeError: map.setCenter is not a function
So I have to use that code instead:
GoogleMaps.ready('exampleMap', function(map) {
// Add a marker to the map once it's ready
Tracker.autorun(function() {
if(Session.get('lat') && Session.get('lng')) {
GoogleMaps.maps.exampleMap.instance.setCenter({ lat: Session.get('lat'), lng: Session.get('lng') });
}
});
});
How come? I found it to cause issue everywhere, let's say in my geocoder function, where I add a market, I get
InvalidValueError: setMap: not an instance of Map; and not an instance of StreetViewPanorama
if I use map instead of the whole map instance call in the following code:
function geocodeAddress(gc, map) {
var address = Product.findOne({permalink: FlowRouter.getParam('product')}).realAddress;
gc.geocode({'address': address}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
Session.set({
"lat": results[0].geometry.location.lat(),
"lng": results[0].geometry.location.lng()
});
var marker = new google.maps.Marker({
map: GoogleMaps.maps.exampleMap.instance,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
Thanks for your help, I might have totally screw up something as it is my first time dealing with it so feel free to point out how I can make it better or if you need more informations :).
EDIT: Solved, it was pretty stupid, I needed to use map.instance.setCenter, however I'd like a confirmation that this is the "way to go" before closing if possible :) Thanks a lot and have great day everyone !
Hi, I've been encountering an issue with the "map" in the callback function on .ready().
After implementing a reactive map as seen here, I can't use the "map" argument at all..
This code doesn't work:
It tells me that
So I have to use that code instead:
How come? I found it to cause issue everywhere, let's say in my geocoder function, where I add a market, I get
if I use map instead of the whole map instance call in the following code:
Thanks for your help, I might have totally screw up something as it is my first time dealing with it so feel free to point out how I can make it better or if you need more informations :).