Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stimulus init #474

Merged
merged 2 commits into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions assets/dist/googlemaps_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ var _default = /*#__PURE__*/function (_Controller) {
var _this = this;

this._prepareApi(this.apiKeyValue).then(function () {
_this.element.style.height = _this.heightValue + 'px';

var options = _objectSpread(_objectSpread({}, _this.defaultOptions), {}, {
latitude: _this.latitudeValue,
longitude: _this.longitudeValue,
Expand Down Expand Up @@ -174,7 +176,7 @@ exports["default"] = _default;
longitude: Number,
zoom: Number,
height: Number,
title: Boolean,
title: String,
icon: String,
apiKey: String
});
Expand All @@ -184,8 +186,5 @@ exports["default"] = _default;
mapTypeControl: false,
scaleControl: false,
draggable: false,
scrollwheel: false,
title: false,
icon: false,
apiKey: ''
scrollwheel: false
});
3 changes: 2 additions & 1 deletion assets/dist/openstreetmap_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ var _default = /*#__PURE__*/function (_Controller) {
var marker = L.marker(position, markerOptions);

if (this.titleValue) {
marker.bindPopup(this.titleValue).openPopup();
var popup = L.popup().setContent(this.titleValue);
marker.bindPopup(popup).openPopup();
}

return marker;
Expand Down
7 changes: 3 additions & 4 deletions assets/src/googlemaps_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class extends Controller {
longitude: Number,
zoom: Number,
height: Number,
title: Boolean,
title: String,
icon: String,
apiKey: String,
};
Expand All @@ -20,13 +20,12 @@ export default class extends Controller {
scaleControl: false,
draggable: false,
scrollwheel: false,
title: false,
icon: false,
apiKey: '',
};

connect() {
this._prepareApi(this.apiKeyValue).then(() => {
this.element.style.height = this.heightValue + 'px';

let options = {
...this.defaultOptions,
latitude: this.latitudeValue,
Expand Down
4 changes: 3 additions & 1 deletion assets/src/openstreetmap_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export default class extends Controller {
const marker = L.marker(position, markerOptions);

if (this.titleValue) {
marker.bindPopup(this.titleValue).openPopup();
const popup = L.popup().setContent(this.titleValue);

marker.bindPopup(popup).openPopup();
}

return marker;
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Method Nucleos\\\\MapsBundle\\\\Block\\\\Service\\\\MapBlockService\\:\\:fetchFromAddress\\(\\) should return array\\(float, float\\)\\|null but returns array\\.$#"
count: 1
path: src/Block/Service/MapBlockService.php

-
message: "#^Binary operation \"\\.\" between array\\<string, mixed\\>\\|int\\|string and ' nucleos\\-\\-maps…' results in an error\\.$#"
count: 2
Expand Down
9 changes: 5 additions & 4 deletions src/Block/Service/MapBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private function getCoordinates(BlockContextInterface $blockContext): ?array
$latitude = $blockContext->getSetting('latitude');

if (null !== $longitude && null !== $latitude) {
return [(float) $longitude, (float) $latitude];
return [(float) $latitude, (float) $longitude];
}

$address = $blockContext->getSetting('address');
Expand All @@ -206,13 +206,14 @@ private function getCoordinates(BlockContextInterface $blockContext): ?array
private function fetchFromAddress(string $address): ?array
{
try {
$geo = $this->provider->geocodeQuery(GeocodeQuery::create($address))->first();
$geo = $this->provider->geocodeQuery(GeocodeQuery::create($address))->first();
$coordinates = $geo->getCoordinates();

if (null === $geo->getCoordinates()) {
if (null === $coordinates) {
return null;
}

return $geo->getCoordinates()->toArray();
return [$coordinates->getLatitude(), $coordinates->getLongitude()];
} catch (Exception $e) {
$this->logger->warning(sprintf('Error fetch geo information for %s', $address), [
'exception' => $e,
Expand Down