Merge pull request 'radius calculation for new panorama search based on latitude and mercator projection for google maps' (#36) from feature/more-accurate-new-selection-in-mapeditor-on-google-maps into develop
All checks were successful
default-pipeline default-pipeline #165
All checks were successful
default-pipeline default-pipeline #165
Reviewed-on: https://gitea.e5tv.hu/esoko/mapguesser/pulls/36 Reviewed-by: Pőcze Bence <bence@pocze.ch>
This commit is contained in:
commit
cc24f96395
@ -86,7 +86,7 @@
|
||||
sv.getPanorama({
|
||||
location: location,
|
||||
preference: google.maps.StreetViewPreference.NEAREST,
|
||||
radius: 100,
|
||||
radius: MapEditor.map.getSearchRadius(location),
|
||||
source: canBeIndoor ? google.maps.StreetViewSource.DEFAULT : google.maps.StreetViewSource.OUTDOOR
|
||||
}, function (data, status) {
|
||||
var panoLocationData = status === google.maps.StreetViewStatus.OK ? data.location : null;
|
||||
@ -473,7 +473,11 @@
|
||||
LMapWrapper.markers.removeLayer(marker);
|
||||
},
|
||||
|
||||
toggleStreetViewCover: function () { }
|
||||
toggleStreetViewCover: function () { },
|
||||
|
||||
getSearchRadius: function (location) {
|
||||
return 100;
|
||||
}
|
||||
};
|
||||
|
||||
var GMapWrapper = {
|
||||
@ -626,6 +630,20 @@
|
||||
GMapWrapper.streetViewCover.setMap(GMapWrapper.map);
|
||||
GMapWrapper.streetViewCoverOn = true;
|
||||
}
|
||||
},
|
||||
|
||||
getSearchRadius: function (location) {
|
||||
// source: https://www.yorku.ca/mack/CHI01.htm
|
||||
var movementOffset = 4;
|
||||
|
||||
// source: https://groups.google.com/g/google-maps-js-api-v3/c/hDRO4oHVSeM/m/osOYQYXg2oUJ?pli=1
|
||||
var metersPerPixel = 156543.03392 * Math.cos(location.lat * Math.PI / 180) / Math.pow(2, GMapWrapper.map.getZoom());
|
||||
|
||||
var minSearchRadius = 5;
|
||||
|
||||
var searchRadius = Math.max(minSearchRadius, Math.round(movementOffset * metersPerPixel));
|
||||
|
||||
return searchRadius;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user