Question

This is my first time trying to embed google maps into a webpage. I've followed instructions from the API site, and I've Googled other maps, but what I'm seeing doesn't seem to help.

Here's what I've got.

<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
// Enable the visual refresh
google.maps.visualRefresh = true;

function initialize() {
    var map_canvas = document.getElementById('map_canvas');
    var map_options = {
        center: new google.maps.LatLng(51.54968,-0.16305),
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP      
    }
    var map = new google.maps.Map(map_canvas, map_options);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Was it helpful?

Solution

Your code doesn't create a marker. You should add something like

var marker = new google.maps.Marker({
    position: new google.maps.LatLng(51.54968,-0.16305), 
    map: map,
    title: "One title"
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top