the issue is not produced on first page load, map works correcrly at first, but after a an ajax call the map gives the below error in (check.js.erb) any idea why this error is produced, and how to fix it?
Uncaught TypeError: Cannot read property 'addMarker' of undefined
at Handler.Gmaps.Objects.Handler.Handler.addMarker
at Function._.map._.collect
at Handler.Gmaps.Objects.Handler.Handler.addMarkers
at eval (eval at <anonymous>
at tg.<anonymous>
at tg.<anonymous>
at _.B.trigger
at common.js:27
at Hx.G (map.js:31)
Handler.prototype.addMarker = function(marker_data, provider_options) {
var marker;
marker = this._builder('Marker').build(marker_data, provider_options, this.marker_options);
marker.setMap(this.getMap());
this.clusterer.addMarker(marker); //cluster has no addMarker
return marker;
};
Below is the code relevent code:-
hunts#play creates an initial map. if click on verify position link the hunts#check re-creates a map in check.js.erb with new markers
hunts_controller:-
def play
@checkpoint = @hunt.checkpoints.first
@hash = Gmaps4rails.build_markers(@checkpoint) do |check, marker|
marker.lat check.lat
marker.lng check.log
end
end
def check
checkpoint_id = params[:check][:checkpoint_id]
@current_checkpoint = Checkpoint.find(checkpoint_id)
latitude = params[:check][:latitude]
longitude = params[:check][:longitude]
accuracy = params[:check][:accuracy]
loc_nav = [latitude, longitude]
loc_checkpoint = [@current_checkpoint.lat , @current_checkpoint.log ]
distance = Geocoder::Calculations.distance_between(loc_nav,loc_checkpoint)
if (distance + accuracy.to_f) > 70 # 70 supposed min distance to treasure
@checkpoint = @current_checkpoint.lower_item
else
@checkpoint = @current_checkpoint
end
@hash = Gmaps4rails.build_markers(@checkpoint) do |check, marker|
marker.lat check.lat
marker.lng check.log
end
end
the issue is not produced on first page load, map works correcrly at first, but after a an ajax call the map gives the below error in (check.js.erb) any idea why this error is produced, and how to fix it?
the code https://github.com/thebatu/escapin_city. Using latest version of the gem.
Below is the code relevent code:- hunts#play creates an initial map. if click on verify position link the hunts#check re-creates a map in check.js.erb with new markers