title: OpenLayer load map with initial marker
body: <p>I'm using OpenLayer v4.6.5 to display a map in my html page. I need to show markers in my map. It works fine when clicking on map, but I can't load map initially displaying a marker on it. Why the last line of code has no effect? </p>
  
  <pre><code>&lt;link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css"&gt;
  &lt;script src="https://openlayers.org/en/v4.6.5/build/ol.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  function createMap(){
          var coordinate = someCoordinate;
          var vectorSource = new ol.source.Vector({});
          var vectorLayer = new ol.layer.Vector({ source: vectorSource });
          var view = new ol.View({ center: ol.proj.fromLonLat(coordinate), zoom: 12, maxZoom: 19, minZoom: 5 });
          var map = new ol.Map({
              layers: [new ol.layer.Tile({ source: new ol.source.OSM({ key: 'myKey', crossOrigin: '' }) }), vectorLayer,],
              target: document.getElementById(mapId),
              controls: ol.control.defaults(),
              view: view
          });
  
          // create custom marker image with custom text in bottom
          var iconStyle = new ol.style.Style({
              image: new ol.style.Icon({
                  anchor: [12, 37],
                  anchorXUnits: 'pixels', //'fraction'
                  anchorYUnits: 'pixels',
                  opacity: 0.8,
                  src: 'marker.png'
              })
          });
  
          var marker;
          this.setMarker = function (coordinate) {
              marker = new ol.Feature(
                  new ol.geom.Point(coordinate)
              );
              marker.setStyle(iconStyle);
              vectorSource.addFeature(marker);
          }
  
          map.on('click', function (evt) {
              setMarker(evt.coordinate);
          });
  
          return this;
  }
  
  var map = createMap();
  
  // NOTE: This line of code has no effect!!!
  map.setMarker(someCoordinate)
  
  &lt;/script&gt;
  </code></pre>