|
1 | 1 | {% if not is_googlemaps_loaded() and not gmap.heatmap_layer %} {% if GOOGLEMAPS_KEY %} |
2 | | -<script async src="//maps.googleapis.com/maps/api/js?key={{GOOGLEMAPS_KEY}}&map_ids={{gmap.map_ids}}&language={{gmap.language}}®ion={{gmap.region}}" type="text/javascript"></script> |
| 2 | +<script async src="//maps.googleapis.com/maps/api/js?key={{GOOGLEMAPS_KEY}}&map_ids={{gmap.map_ids}}&language={{gmap.language}}®ion={{gmap.region}}&loading=async" type="text/javascript"></script> |
3 | 3 | {% else %} |
4 | | -<script async src="//maps.googleapis.com/maps/api/js?language={{gmap.language}}®ion={{gmap.region}}" type="text/javascript"></script> |
| 4 | +<script async src="//maps.googleapis.com/maps/api/js?language={{gmap.language}}®ion={{gmap.region}}&loading=async" type="text/javascript"></script> |
5 | 5 | {% endif %} {{ set_googlemaps_loaded() }} {% endif %}{% if gmap.cluster %} |
6 | 6 | <script src="//cdnjs.cloudflare.com/ajax/libs/js-marker-clusterer/1.0.0/markerclusterer_compiled.js" type="text/javascript"></script> |
7 | 7 | {% endif %}{% if gmap.heatmap_layer %}{% if GOOGLEMAPS_KEY %} |
8 | | -<script async src="//maps.googleapis.com/maps/api/js?key={{GOOGLEMAPS_KEY}}&map_ids={{gmap.map_ids}}&language={{gmap.language}}®ion={{gmap.region}}&libraries=visualization" type="text/javascript"></script> |
| 8 | +<script async src="//maps.googleapis.com/maps/api/js?key={{GOOGLEMAPS_KEY}}&map_ids={{gmap.map_ids}}&language={{gmap.language}}®ion={{gmap.region}}&libraries=visualization&loading=async" type="text/javascript"></script> |
9 | 9 | {% endif %}{% endif%} |
10 | 10 |
|
11 | 11 |
|
|
82 | 82 | {% endif %} |
83 | 83 |
|
84 | 84 | // add gmap markers |
85 | | - var raw_markers = {{gmap.markers|tojson|safe}}; |
86 | | - const { AdvancedMarkerElement } = await google.maps.importLibrary("marker"); |
87 | | - for(i=0; i<{{gmap.markers|length}};i++) { |
| 85 | + const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary("marker"); |
| 86 | + |
| 87 | + for (const marker of {{gmap.markers|tojson|safe}}) { |
88 | 88 | tempMarker = new AdvancedMarkerElement({ |
89 | | - position: new google.maps.LatLng(raw_markers[i].lat, raw_markers[i].lng), |
| 89 | + position: new google.maps.LatLng(marker.lat, marker.lng), |
90 | 90 | map: {{gmap.varname}}, |
91 | | - title: raw_markers[i].title ? raw_markers[i].title : null, |
| 91 | + title: marker.title ? marker.title : null, |
| 92 | + content: new PinElement({ |
| 93 | + glyphColor: marker.pin.glyph_color, |
| 94 | + background: marker.pin.background, |
| 95 | + borderColor: marker.pin.border_color, |
| 96 | + glyph: marker.pin.glyph, |
| 97 | + }).element, |
92 | 98 | }); |
93 | 99 |
|
94 | 100 |
|
95 | | - if(raw_markers[i].infobox) |
| 101 | + if(marker.infobox) |
96 | 102 | { |
97 | 103 | google.maps.event.addListener( |
98 | 104 | tempMarker, |
99 | 105 | 'click', |
100 | | - getInfoCallback({{gmap.varname}}, raw_markers[i].infobox) |
| 106 | + getInfoCallback({{gmap.varname}}, marker.infobox) |
101 | 107 | ); |
102 | 108 | } |
103 | 109 |
|
|
106 | 112 | google.maps.event.addListener( |
107 | 113 | tempMarker, |
108 | 114 | 'click', |
109 | | - function (event) { markerClickposCallback('{{gmap.markerClickpos_uri}}', event.latLng, raw_markers[i].title, raw_markers[i].label)} |
| 115 | + function (event) { markerClickposCallback('{{gmap.markerClickpos_uri}}', event.latLng, marker.title, marker.label)} |
110 | 116 | ); |
111 | 117 | } |
112 | | - {{gmap.varname}}_markers[i] = tempMarker; |
| 118 | + {{gmap.varname}}_markers.push(tempMarker); |
113 | 119 |
|
114 | 120 | } |
115 | 121 |
|
|
0 commit comments