UNPKG

openlayers

Version:

Build tools and sources for developing OpenLayers based mapping applications

29 lines (28 loc) 1.43 kB
--- layout: example.html title: Advanced View Positioning shortdesc: This example demonstrates how a map's view can be adjusted so a geometry or coordinate is positioned at a specific pixel location. docs: > This example demonstrates how a map's view can be adjusted so a geometry or coordinate is positioned at a specific pixel location. The map above has top, right, bottom, and left padding applied inside the viewport. The view's <code>fit</code> method is used to fit a geometry in the view with the same padding. The view's <code>centerOn</code> method is used to position a coordinate (Lausanne) at a specific pixel location (the center of the black box). <p>Use <code>Alt+Shift+Drag</code> to rotate the map.</p> tags: "center, rotation, openstreetmap" --- <div class="mapcontainer"> <div id="map" class="map"></div> <div class="padding-top"></div> <div class="padding-left"></div> <div class="padding-right"></div> <div class="padding-bottom"></div> <div class="center"></div> </div> <button id="zoomtoswitzerlandbest">Zoom to Switzerland</button> (best fit),<br/> <button id="zoomtoswitzerlandconstrained">Zoom to Switzerland</button> (respect resolution constraint).<br/> <button id="zoomtoswitzerlandnearest">Zoom to Switzerland</button> (nearest),<br/> <button id="zoomtolausanne">Zoom to Lausanne</button> (with min resolution),<br/> <button id="centerlausanne">Center on Lausanne</button>