What I am trying to do here. When I press the marker. It should send me to the that id's page. It sending me to id's page. But it doesn't matter which marker I click I always going to same id's page. Listener is not working properly... I guess...
This is the full map:
var estates = <?php echo json_encode($estates);?>;
function initMap()
{
var options =
{
zoom : 6,
center : {lat:34.652500, lng:135.506302}
};
var map = new google.maps.Map(document.getElementById('map'), options);
@foreach ($estates as $est)
var marker = new google.maps.Marker({
map: map,
icon: 'imgs/marker.png',
url: "/pages/",
label: {
text: estates.data[0].price.substring(0, 5),
color: "#fff",
},
position: {
lat: ,
lng:
}
});
google.maps.event.addListener(marker, 'click', function () {
window.location.href = marker.url;
});
@endforeach
}
Any idea to fix this problem?
from Marker event.listener iteration issue, Laravel
No comments:
Post a Comment