Answer the question
In order to leave comments, you need to log in
How to display google maps in a loop?
Hello.
There is this code:
<div class="contacts col-xs-12">
<div class="contact-block row">
<div class="maps col-lg-9" data-addr="<?= $address['address'] ?>"></div>
</div>
<div class="contact-block row">
<div class="maps col-lg-9" data-addr="<?= $address['address'] ?>"></div>
</div>
</div>
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&callback=initMap" async defer></script>
<script type="text/javascript">
var map;
function initMap() {
var element = $('.contact-block');
element.each(function () {
var self = $(this);
var container = self.find('.maps');
var addr = container.data('addr');
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': addr}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
console.info(results);
var map = new google.maps.Map(container, {
zoom: 17,
center: results[0].geometry.location
});
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
});
}
</script>
Uncaught TypeError: Cannot set property 'position' of undefined
Answer the question
In order to leave comments, you need to log in
Well, look at the js connected there:
https://fund.cindicator.com/assets/app_f99b034ca79...
Look in the code for the block id, namely "HowItWorks" and you will see how it is implemented.
But in order to receive specific answers, it is advisable to ask specific questions . Because "such a scroll" requires decoding. There's a lot of things done and what exactly you don't understand - it's not clear. They will not tell you step by step in the answers how to make a whole site.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question