Skip to content

Commit

Permalink
Fix collision layer
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolai-b committed Jul 11, 2016
1 parent 2048291 commit 887a5fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion config/initializers/geo.rb
Expand Up @@ -6,7 +6,6 @@ module Geo
NOWHERE_IN_PARTICULAR = RGeo::Geos.factory(has_z_coordinate: true).point(0.1275, 51.5032, 6)
ISSUE_MAX_AREA = 0.1 # square degrees

COLLISIONS_API_KEY = 'b7af2f6899b5d784'
COLLISIONS_URL = 'https://api.cyclestreets.net/v2/collisions.locations'
end

Expand Down
22 changes: 11 additions & 11 deletions vendor/assets/javascripts/leaflet-layerjson.src.js
Expand Up @@ -28,7 +28,7 @@ L.LayerJSON = L.FeatureGroup.extend({
buildPopup: null, //function popup builder
optsPopup: null, //popup options
buildIcon: null, //function icon builder
hashGenerator: null, //function to generate a unique element per feature
hashGenerator: null, //function to generate a unique element per feature. Takes a data point and a latlng, must return a unique string
//
minZoom: 10, //min zoom for call data
caching: true, //enable requests caching
Expand Down Expand Up @@ -128,7 +128,7 @@ L.LayerJSON = L.FeatureGroup.extend({
L.FeatureGroup.prototype.clearLayers.call(this);
return this;
},

_debouncer: function(func, timeout) {
var timeoutID;
timeout = timeout || 300;
Expand Down Expand Up @@ -173,8 +173,13 @@ L.LayerJSON = L.FeatureGroup.extend({
return marker;
},

_defaultHashGenerator: function(data, propLoc) {
var latlng;
_defaultHashGenerator: function(data, latlng) {
return [latlng.lat,latlng.lng].join() + this._getPath(data, this.options.propertyTitle);
},

addMarker: function(data) {
var latlng, hash, propLoc = this.options.propertyLoc;

if( L.Util.isArray(propLoc) ) {
latlng = L.latLng( parseFloat( this._getPath(data, propLoc[0]) ),
parseFloat( this._getPath(data, propLoc[1]) ) );
Expand All @@ -187,13 +192,8 @@ L.LayerJSON = L.FeatureGroup.extend({
latlng = L.latLng( this._getPath(data, propLoc) );
}
}
return [latlng.lat,latlng.lng].join() + this._getPath(data, this.options.propertyTitle);
},

addMarker: function(data) {
var latlng, hash, propLoc = this.options.propertyLoc;

hash = this._hashGenerator(data, propLoc);
hash = this._hashGenerator(data, latlng);

if(typeof this._markersCache[hash] === 'undefined')
this._markersCache[hash] = this._dataToMarker(data, latlng);
Expand Down Expand Up @@ -318,7 +318,7 @@ L.LayerJSON = L.FeatureGroup.extend({
else
response = eval("("+ request.responseText + ")");
} catch(err) {
response = {};
response = {};
throw new Error('Ajax response is not JSON');
}
cb(response);
Expand Down

0 comments on commit 887a5fb

Please sign in to comment.