Código
<!DOCTYPE html> <html lang="en"> <head> <meta charset=utf-8> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> <script type="text/javascript"> var map = null; var infoWindow = null; function openInfoWindow(marker) { var markerLatLng = marker.getPosition(); infoWindow.setContent([ '<b>La posicion del marcador es:</b><br/>', markerLatLng.lat(), ', ', markerLatLng.lng(), '<br/><br/>Arrástrame y haz click para actualizar la posición.' ].join('')); infoWindow.open(map, marker); } function initialize() { var myLatlng = new google.maps.LatLng(20.68017,-101.35437); var myOptions = { zoom: 13, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map($("#map_canvas").get(0), myOptions); infoWindow = new google.maps.InfoWindow(); var marker = new google.maps.Marker({ position: myLatlng, draggable: true, map: map, title:"Ejemplo marcador arrastrable" }); google.maps.event.addListener(marker, 'click', function(){ openInfoWindow(marker); }); } $(document).ready(function() { initialize(); }); var variablejs = "contenido de la variable javascript"; </script> </head> <body> <div id="map_canvas" style="width: 640px; height: 400px;"></div> <?php $variablephp = "<script> document.write(markerLatLng)</script>"; //La variable está mal, ya que no se cual poner ni como sacarla correctamente. echo $variablephp; ?> </body> </html>
Un saludo y gracias!