Closed t-prod closed 3 years ago
You can only check the bounds of the map, once the map is actually loaded, so you need to use the event after load.
Mapper::location('Paris')->map(['marker' => true, 'zoom' => 5, 'center' => true, 'eventAfterLoad' => 'mapEvent(map, markers);']);
<script type="text/javascript">
function mapEvent(map, markers) {
let bounds = map.getBounds();
for (let i=0; i<markers.length; i++){
if(bounds.contains(markers[i].getPosition()) ){
console.log(markers[i].getLabel());
}
}
}
</script>
Hi,
I try to display all markers on the map. To do it I use this :
Mapper::location('Paris')->map(['marker' => true, 'zoom' => 5, 'center' => true, 'eventBeforeLoad' => 'mapEvent(map);']);
Function in JS is like this but markers are undefined, do you have an idea ? :
Regards