Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple google map using php [closed]

new to web development and was just wondering if there was an easy way of drawing simple latitude and longitude coordinates from a table and rendering them on a map. I have created a simple place page that uses php to draw the name, address etc from each stored place within a place table. I just want to create a really simple map that would display a marker at the lat and lng coordinates. Sorry if this is a silly question.

like image 863
Jane O 'Donoghue Avatar asked Mar 25 '26 20:03

Jane O 'Donoghue


1 Answers

This is not a PHP issue. It uses javascript.

This should do it:

<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
    var myMap;
    var myLatlng = new google.maps.LatLng(52.518903284520796,-1.450427753967233);
    function initialize() {
        var mapOptions = {
            zoom: 13,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP  ,
            scrollwheel: false
        }
        myMap = new google.maps.Map(document.getElementById('map'), mapOptions);
        var marker = new google.maps.Marker({
            position: myLatlng,
            map: myMap,
            title: 'Name Of Business',
            icon: 'http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png'
        });
    }
    google.maps.event.addDomListener(window, 'load', initialize);
</script>

<div id="map" style="width:500px; height: 500px;">

</div>

Just Change the myLatLng Variable to what you want.

Here's the documentation if you need more help: https://developers.google.com/maps/documentation/javascript/tutorial#HelloWorld

like image 142
Yahya Uddin Avatar answered Mar 28 '26 08:03

Yahya Uddin