do not exclude indoor panoramas
All checks were successful
default-pipeline default-pipeline #166

This commit is contained in:
Bence Pőcze 2021-05-02 18:38:29 +02:00
parent cc24f96395
commit 11eee64895
Signed by: bence
GPG Key ID: AA52B11A3269D1C1
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();