Google Map with Laravel

isurutmv

Well-known member
  • May 1, 2013
    1,936
    823
    113
    29
    Gampaha
    mcn mata laravel project ekakakata google map daganna oone pahala thiyena widihata karama me error eka enawa meka karanna widihak kiyahallako :sorry::sorry::sorry:

    30nd8pv.png
    qz5fkx.png



    14e71tt.png
     

    UserDone

    Junior member
  • Mar 25, 2018
    84
    29
    18
    Console තියන දේ වලින් decision ගන්න අමාරුයි :eek:, ඒත් මම run කරන script එකක් දෙන්නම්. මේකෙ line no 50 තියන {API KEY} එක තමන්ගේ key එකෙන් replace කරන් run කරල බලන්න.

    HTML:
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
         <script src="resources/jquery-3.2.1/script.js"></script>
    </head>
    <body>
        <div id="googleMap" style="width:100%;height:500px;"></div>   
        <script>
            function generate_location_maps() {
    
                google.maps.event.addDomListener(window, 'load', initialize('293/1, Highlevel Road, Pannipitiya, Sri Lanka'));
    
                function initialize(address) {
    
                    var geocoder = new google.maps.Geocoder();
                    var marker;
                    var map;
                    var position;
    
                    var mapOptions = {
                        zoom: 15,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
                    map = new google.maps.Map(document.getElementById('googleMap'),
                    mapOptions);
    
                    geocoder.geocode({
                        'address': address
                    }, function (results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            position = results[0].geometry.location;
                            marker = new google.maps.Marker({
                                map: map,
                                position: position
                            });
                            map.setCenter(marker.getPosition());
    
                            google.maps.event.addListenerOnce(map, 'idle', function() {
                                setTimeout(function() {
                            google.maps.event.trigger(marker, 'click');
                                },0);
                        });
                        }
                    });
                }
     
            }
        </script>  
        <script src="https://maps.googleapis.com/maps/api/js?key={API KEY}&callback=generate_location_maps"></script>     
    </body>
    </html>
     

    isurutmv

    Well-known member
  • May 1, 2013
    1,936
    823
    113
    29
    Gampaha
    Console තියන දේ වලින් decision ගන්න අමාරුයි :eek:, ඒත් මම run කරන script එකක් දෙන්නම්. මේකෙ line no 50 තියන {API KEY} එක තමන්ගේ key එකෙන් replace කරන් run කරල බලන්න.

    HTML:
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
         <script src="resources/jquery-3.2.1/script.js"></script>
    </head>
    <body>
        <div id="googleMap" style="width:100%;height:500px;"></div>   
        <script>
            function generate_location_maps() {
    
                google.maps.event.addDomListener(window, 'load', initialize('293/1, Highlevel Road, Pannipitiya, Sri Lanka'));
    
                function initialize(address) {
    
                    var geocoder = new google.maps.Geocoder();
                    var marker;
                    var map;
                    var position;
    
                    var mapOptions = {
                        zoom: 15,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
                    map = new google.maps.Map(document.getElementById('googleMap'),
                    mapOptions);
    
                    geocoder.geocode({
                        'address': address
                    }, function (results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            position = results[0].geometry.location;
                            marker = new google.maps.Marker({
                                map: map,
                                position: position
                            });
                            map.setCenter(marker.getPosition());
    
                            google.maps.event.addListenerOnce(map, 'idle', function() {
                                setTimeout(function() {
                            google.maps.event.trigger(marker, 'click');
                                },0);
                        });
                        }
                    });
                }
     
            }
        </script>  
        <script src="https://maps.googleapis.com/maps/api/js?key={API KEY}&callback=generate_location_maps"></script>     
    </body>
    </html>

    thank you mcn:yes::yes::yes: