Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to call your addMarker function in the initialize function so the markers are added <em>after</em> the map is initialized, not before. You have 2 options for initializing the map property of the marker either 1. make it global or 2. pass it in to the addMarker function (as below). Also note that map_canvas is a HTML DOM element, not a google.maps.Map, the name of that variable is "map".</p> <pre><code>function initialize() { var map_canvas = document.getElementById('map_canvas'); var map_options = { scrollwheel: false, zoom: 16, center: new google.maps.LatLng(51.840164,4.33244), mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, position: google.maps.ControlPosition.TOP }, panControl: false, panControlOptions: { position: google.maps.ControlPosition.TOP_RIGHT }, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE, position: google.maps.ControlPosition.LEFT_CENTER }, scaleControl: false, scaleControlOptions: { position: google.maps.ControlPosition.TOP_LEFT }, streetViewControl: false, streetViewControlOptions: { position: google.maps.ControlPosition.LEFT_CENTER } } var map = new google.maps.Map(map_canvas, map_options) var features = [ { position: new google.maps.LatLng(51.840164,4.33244), } ]; for (var i = 0, feature; feature = features[i]; i++) { addMarker(feature, map); } } function addMarker(feature, map) { var marker = new google.maps.Marker({ position: feature.position, icon: 'locationpointer.png', map: map }); } google.maps.event.addDomListener(window, 'load', initialize); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload