Last active
August 29, 2015 14:26
-
-
Save pgiraud/540f0c89c2f71931859a to your computer and use it in GitHub Desktop.
OL3 interaction select 3.7.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Select features example</title> | |
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.7.0/ol.css" type="text/css"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.7.0/ol.js"></script> | |
<style> | |
.map { | |
width: 256px; | |
height: 256px; | |
} | |
</style> | |
</head> | |
<body> | |
<p>Layer specified for the select interaction</p> | |
<div id="map" class="map"></div> | |
<p>No layer specified for the select interaction</p> | |
<div id="map2" class="map"></div> | |
</div> | |
</div> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var source = new ol.source.Vector({ | |
features: [ | |
new ol.Feature({ | |
geometry: new ol.geom.Polygon([[[-2e6, -2e6], [-2e6, 2e6], [2e6, 2e6], | |
[2e6, -2e6], [-2e6, -2e6]]]) | |
}) | |
] | |
}); | |
var vector = new ol.layer.Vector({ | |
source: source | |
}); | |
var map = new ol.Map({ | |
layers: [vector], | |
target: 'map', | |
view: new ol.View({ | |
center: [0, 0], | |
zoom: 2 | |
}) | |
}); | |
var interaction = new ol.interaction.Select({ | |
layers: [vector], | |
condition: ol.events.condition.pointerMove | |
}); | |
map.addInteraction(interaction); | |
var map2 = new ol.Map({ | |
layers: [vector], | |
target: 'map2', | |
view: new ol.View({ | |
center: [0, 0], | |
zoom: 2 | |
}) | |
}); | |
var interaction2 = new ol.interaction.Select({ | |
condition: ol.events.condition.pointerMove | |
}); | |
map2.addInteraction(interaction2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment