Merge pull request #6224 from aAXEe/pinZoom-allowFractionalZoom

Pinch zoom: allow fractional zoom
This commit is contained in:
Tim Schaub
2016-12-09 10:22:05 -07:00
committed by GitHub
5 changed files with 70 additions and 7 deletions

10
examples/pinchZoom.html Normal file
View File

@@ -0,0 +1,10 @@
---
layout: example.html
title: PinchZoom
shortdesc: A basic example for a pinch zoom with a restriction to integer zooms.
docs: >
<p>Use a pinch zoom gesture to zoom the map.
After the gesture the map will zoomed to the next whole-number zoom level with an animtation.</p>
tags: "pinch, zoom, interaction"
---
<div id="map" class="map"></div>

25
examples/pinchZoom.js Normal file
View File

@@ -0,0 +1,25 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.interaction');
goog.require('ol.interaction.PinchZoom');
goog.require('ol.layer.Tile');
goog.require('ol.source.OSM');
var map = new ol.Map({
interactions: ol.interaction.defaults({pinchZoom: false}).extend([
new ol.interaction.PinchZoom({
constrainResolution: true // force zooming to a integer zoom
})
]),
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});