doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 9 forks source link

Help with static map styles in PHP #70

Closed daltonrooney closed 1 year ago

daltonrooney commented 1 year ago

I'm trying to apply some map styles in a PHP implementation & seem to be missing something. I first tried converting the style object to PHP array syntax like so:

$mapStyles = [
  [
    "featureType" => "poi.business",
    "stylers" => [
      [
        "visibility" => "off"
      ]
    ]
  ]
];

Which results in a PHP Array to string conversion error in doublesecretagency/craft-googlemaps/src/models/StaticMap.php at line 235. So I tried using json_decode with the JSON that I got from Google like this:

$mapStyles = json_decode('[
  {
    "featureType": "poi.business",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]');

But got the same error. Is there an example of a working style config in PHP I could reference? Thanks so much!

Google Maps plugin version 2.5.2 Craft CMS version 4.3.1

lindseydiloreto commented 1 year ago

This is fixed, and will be available in the next release. The styles option for static maps should now behave as expected.

If you'd like to get the latest dev version now, change your composer.json file to say...

"doublesecretagency/craft-googlemaps": "dev-v4-dev"

... and then run composer update.

Thanks for filing this issue! 🍺

lindseydiloreto commented 1 year ago

This patch has been officially released in v4.3. 👍