maps, php, sql. Inserting coordinates into the database and reaver map (google) with these coordinates

1

I have a dynamic map (at least I would like it to be), I wanted it to depend on the user, it introduced the coordinates (based on a form) I wanted and they were entered into the database ... so far so good. But then how did you introduce these coordinates into google maps formatting in the 'center' parameter?

    <script type="text/javascript">

                google.maps.event.addDomListener(window, 'load', init);

                function init() {

                    var mapOptions = {
                        zoom: 14,
                        center: new google.maps.LatLng(LAT(COOR1), LONG(COORD2)),
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        mapTypeControl: false,
                        streetViewControl: false,
                        scrollwheel: false,
                        panControl: false,
     };



    var mapElement = document.getElementById('map');


                var map = new google.maps.Map(mapElement, mapOptions);
            }
    
asked by anonymous 19.09.2014 / 13:17

1 answer

1

I did it this way:

<?php
$lat = '38.689527';
$long = '-9.351307';
echo '<script type="text/javascript">

    google.maps.event.addDomListener(window, "load", init);
    function init() {
        var mapOptions = {
            zoom: 14,
            center: new google.maps.LatLng(' .$lat. ', ' .$long. '),
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            mapTypeControl: false,
            streetViewControl: false,
            scrollwheel: false,
            panControl: false,
        };
        var mapElement = document.getElementById("map");
        var map = new google.maps.Map(mapElement, mapOptions);
    }

</script>';
    
19.09.2014 / 13:53