You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a map showing (ideally) every marker from within a channel of restaurants.
There are a total of 80 markers across 76 entries.
In the database, I can see 80 rows in craft_googlemaps_locations.
From what I can tell, this means they've all been geocoded and so can just be output without needing to contact google on page load (and therefore avoid the limit).
Yet when I load the page, I only get a maximum of 11 markers.
Searching the source for "new GoogleMaps.Marker" returns 80 results.
The code I'm using is:
{% set options =
{
id: 'map',
width: '100%',
height: '700px',
options:
{
minZoom: 11
}
}
%}
{{ craft.googleMaps.map(options) }}
{% for restaurant in restaurants %}
{% for marker in restaurant.address.getMarkers() %}
{% set mrkrContent =
'<strong>' ~
restaurant.title ~
'</strong><br>' ~
marker.address|replace({',': "<br>"})|raw
%}
{% set marker =
{
address: marker.address,
content: mrkrContent
}
%}
{{ craft.googleMaps.marker('map', marker) }}
{% endfor %}
{% endfor %}
Plugin settings are as follows:
Am I doing something completely wrong?
The text was updated successfully, but these errors were encountered:
In case anyone has this same issue, I think it's to do with using "address". Presumably if there's a latlng parameter, you could pass that with the stored values, but I can't find any reference to that existing.
What I did instead was build an array of the data and then output it as JSON and just handled it all in the js.
{% set mapData = {} %}
{% for restaurant in restaurants %}
{% for marker in restaurant.address.getMarkers() %}
{% set mrkr = {
'content' : '<strong>' ~ restaurant.title ~ '</strong>',
'lat' : marker.lat,
'lng' : marker.lng,
'website' : restaurant.website,
'opinion' : restaurant.opinion.first()|snake
} %}
{% set key = restaurant.slug ~ '-' ~ loop.index %}
{% set mapData = mapData|merge({ (key) : mrkr }) %}
{% endfor %}
{% endfor %}
<script>
var mapData = {{ mapData|json_encode|raw }};
</script>
<div id="gmap" class="gmap js-gmap"></div>
I have a map showing (ideally) every marker from within a channel of restaurants.
There are a total of 80 markers across 76 entries.
In the database, I can see 80 rows in craft_googlemaps_locations.
From what I can tell, this means they've all been geocoded and so can just be output without needing to contact google on page load (and therefore avoid the limit).
Yet when I load the page, I only get a maximum of 11 markers.
Searching the source for "new GoogleMaps.Marker" returns 80 results.
The code I'm using is:
Plugin settings are as follows:
Am I doing something completely wrong?
The text was updated successfully, but these errors were encountered: