I am trying to add simple map in Apex Page. But it is not getting displayed.

<apex:page >
  #map_canvas {
    width: 500px;
    height: 400px;
    background-color: #CCC;
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    function initialize() {
        var map_canvas = document.getElementById('map_canvas');
        var mapOptions = {
          center: new google.maps.LatLng(44.5403, -78.5463),
          zoom: 8,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        var map = new google.maps.Map(map_canvas, map_options);
    google.maps.event.addDomListener(window, 'load', initialize);
<div id="map_canvas"></div>

at line var map = new google.maps.Map(map_canvas, map_options); change map_options to mapOptions,

Always check for errors in error console when you work with JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.