0

I created a simple OpenLayers3 map with the plugin Qgis2web. It consists of a basemap with points. Every point has its own popup. This is the html code for the map and for the popup.

<div id="map">
        <div id="popup" class="ol-popup">
            <a href="#" id="popup-closer" class="ol-popup-closer"></a>
            <div id="popup-content"></div>
        </div>
    </div>

The popup content is often large, and I need the function "autopan" to move the map to show the entire content of the popup. I modified the javascript code created by Qgis2web this way, as I found in some examples on the web:

var overlayPopup = new ol.Overlay(/** @type {olx.OverlayOptions} */ ({
element: container,
positioning: 'center-center',
autoPan: true,
autoPanAnimation: {
duration: 450
},
}));

The result is that sometimes the autopan works, and sometimes it doesn't work. There is not a rule, as far as I can see. How can I modify the code to make it always work?

  • 1
    Do you see any errors in your browser console (F12 to open dev tools, then click Console tab)? – Tom Chadwin May 12 '16 at 12:07
  • @TomChadwin No errors just checked – Vale May 12 '16 at 12:30

Your Answer

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

Browse other questions tagged or ask your own question.