Buenas noches, tengo esté código que me genera marcadores dinámicos desde una base de datos mysql y dentro del infowindow he añadido un botón pero no consigo que me ejecute la función que es basicamente escribir el id del botón en un campo input de un formulario.
Código HTML:
<script type="text/javascript">
var map = null;
var infoWindow = null;
function closeInfoWindow() {
infoWindow.close();
}
function initialize() {
var myLatlng = new google.maps.LatLng(<?php echo $row_Recordset3['Latitud']; ?>,<?php echo $row_Recordset3['Longitud']; ?>);
var myOptions = {
zoom: 11,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map($("#map_canvas2").get(0), myOptions);
infoWindow = new google.maps.InfoWindow();
google.maps.event.addListener(map, 'click', function(){
closeInfoWindow();
});
<?php do{?>
var marker<?php echo $row_Recordset3['idLugar']; ?> = new google.maps.Marker({
position: new google.maps.LatLng(<?php echo $row_Recordset3['Latitud']; ?>,<?php echo $row_Recordset3['Longitud']; ?>),
draggable: false,
map: map
});
google.maps.event.addListener(marker<?php echo $row_Recordset3['idLugar']; ?>, 'click', function(){
function openInfoWindow(marker, content) {
var markerLatLng = marker.getPosition();
infoWindow.setContent ([
'<div style="text-align:center;height:120px; font-size: 16px;">'+
'<div><?php echo $row_Recordset3['Nombre']; ?></div>'+
'<a class="una" id="<?php echo $row_Recordset3['Nombre']; ?>"><div class="foto">Seleccionar</div></a>'+
'</div>'
].join(''));
infoWindow.open(map, marker);
}
openInfoWindow(marker<?php echo $row_Recordset3['idLugar']; ?>, "Marcador <?php echo $row_Recordset3['idLugar']; ?>");
});
<?php } while ($row_Recordset3 = mysql_fetch_assoc($Recordset3)); ?>
}
$(document).ready(function() {
initialize();
});
</script>
<script type="text/javascript">
$('.una').click(function(){
var polid = $(this).attr("id");
document.formevento.ciudad.value = polid;
});
</script>
A ver si alguien podría ayudarme, muchas gracias.