2

I'm trying to output a static map from a smart map field in a matrix. I can output a dynamic map with no issues, but the static map code isn't working.

Here is my code:

{% set locations = entry.locationsAndNotes %}
{% set options = {
    width: 370,
    height: 208,
    zoom: 16,
} %}
{{ craft.smartMap.img(locations[0], options) }}

The url it outputs looks like this: https://maps.googleapis.com/maps/api/staticmap?visual_refresh=true&key=myKey&scale=2&center=-48.876667,-123.393333&size=370x208&maptype=roadmap&zoom=16 Pasted into a browser, i get an error that the API server rejected my request because it is missing the size parameter.

If I change all of the &amp to &, an image loads, but it's just a blank blue map.

It seems like this should work, since I can render a dynamic map, but I'm not sure if it's an issue with my code, or the plugin, or the api.

  • If you change craft.smartMap.img to craft.smartMap.map, you're saying it loads the dynamic map properly? Does the marker appear in the correct spot? – Lindsey D Sep 12 '17 at 19:33
  • @LindseyD Yes, changing it to craft.smartMap.map loads the dynamic map with the marker in the correct spot. – artmem Sep 12 '17 at 19:49
  • Looks like a bug... contact support@doublesecretagency.com. – Lindsey D Sep 12 '17 at 20:05
  • for anyone else that comes across this issue in the future - I ran into the same problem, and I needed to a) generate a google-maps API key and b) enable certain APIs in the google api settings - do the stuff on this page: doublesecretagency.com/plugins/smart-map/docs/… - the Google Static Maps API is not enabled by default. – SamC Jan 25 '18 at 17:31