Search code examples
phpjquerygoogle-maps-api-3nyromodal

How to use google maps api v3 in nyromodal


Im trying to embed a map sing google maps api v3 in my nyromodal box but it doesnt happen.

I've tested the code without the modal and it works but when i try to open it on the nyromodal nothing appears.

How can i do it?


Solution

  • Ive just figured out how to do it!

    1 - Insert the js code for google in your index page with 'rel="forceload"' and 'rev="shown"' as the following:

    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false" rel="forceload" rev="shown"></script>

    2 - You insert the code that generates the map inside the modal page as the following:

    <script>
        $(document).ready({
            var mylatlng = new google.maps.LatLng(latitude, longitude);
            var mapProp = {
                center: mylatlng,
                zoom: 15,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("briefmap"), mapProp);
            var marker = new google.maps.Marker({
                position: mylatlng
            });
        });
    </script>