Merge pull request 'do not exclude indoor panoramas' (#37) from feature/pano-could-be-indoor into develop
All checks were successful
default-pipeline default-pipeline #179

Reviewed-on: https://gitea.e5tv.hu/esoko/mapguesser/pulls/37
This commit is contained in:
Bence Pőcze 2021-05-02 18:44:40 +02:00 committed by Gitea
commit 430b32d0c6
No known key found for this signature in database
GPG Key ID: 2E27A8C281A1CC2C
2 changed files with 3 additions and 15 deletions

View File

@ -80,22 +80,16 @@
MapEditor.panorama.setPano(panoLocationData.pano);
},
requestPanoData: function (location, canBeIndoor) {
requestPanoData: function (location) {
var sv = new google.maps.StreetViewService();
sv.getPanorama({
location: location,
preference: google.maps.StreetViewPreference.NEAREST,
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;
if (panoLocationData === null && !canBeIndoor) {
MapEditor.requestPanoData(location, true);
return;
}
document.getElementById('loading').style.visibility = 'hidden';
MapEditor.loadPanoForNewPlace(panoLocationData);

View File

@ -140,7 +140,7 @@ class Place extends Model
return $this->pov->getZoom();
}
public function getFreshPanoId(bool $canBeIndoor = false): ?string
public function getFreshPanoId(): ?string
{
if (
$this->panoIdCachedTimestamp !== null &&
@ -152,19 +152,13 @@ class Place extends Model
$request = new Request('https://maps.googleapis.com/maps/api/streetview/metadata', Request::HTTP_GET);
$request->setQuery([
'key' => $_ENV['GOOGLE_MAPS_SERVER_API_KEY'],
'location' => $this->position->getLat() . ',' . $this->position->getLng(),
'source' => $canBeIndoor ? 'default' : 'outdoor'
'location' => $this->position->getLat() . ',' . $this->position->getLng()
]);
$response = $request->send();
$panoData = json_decode($response->getBody(), true);
$panoId = $panoData['status'] === 'OK' ? $panoData['pano_id'] : null;
// enable indoor panos if no outdoor found
if ($panoId === null && !$canBeIndoor) {
return $this->getFreshPanoId(true);
}
$this->panoIdCached = $panoId;
$this->panoIdCachedTimestamp = new DateTime();