Files
openlayers/tests/manual/select-feature.html
Éric Lemoine f9950ec389 This commit solves the following problem with the select feature control: if
you create two select feature controls on the same vector layer, one with
hover:false that handles geometry type A only, and the other with hover:true
that handles geometry type B only, then if you click on a geometry of type A
and moves out of that geometry, the second control will unselect it. r=tschaub
(closes #1221)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@5975 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2008-02-03 17:20:39 +00:00

151 lines
5.4 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Select Feature Test</title>
<style type="text/css">
body {
font-size: 0.8em;
}
p {
padding-top: 1em;
}
#map {
margin: 1em;
width: 512px;
height: 512px;
}
</style>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map, selectControl1, selectControl2;
function init() {
map = new OpenLayers.Map('map');
var wmsLayer = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'}
);
var vectorLayer = new OpenLayers.Layer.Vector("Vector Layer");
var pointFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(-50, -45)
);
var polygonFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon([
new OpenLayers.Geometry.LinearRing([
new OpenLayers.Geometry.Point(-50,-50),
new OpenLayers.Geometry.Point(-40,-50),
new OpenLayers.Geometry.Point(-40,-40),
new OpenLayers.Geometry.Point(-50,-50)
])
])
);
vectorLayer.addFeatures([pointFeature, polygonFeature]);
map.addLayers([wmsLayer, vectorLayer]);
selectControl1 = new OpenLayers.Control.SelectFeature(
vectorLayer, {geometryTypes: ['OpenLayers.Geometry.Point']}
);
selectControl2 = new OpenLayers.Control.SelectFeature(
vectorLayer, {
geometryTypes: ['OpenLayers.Geometry.Polygon'],
hover: true
});
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(selectControl1);
map.addControl(selectControl2);
selectControl1.activate();
selectControl2.activate();
map.setCenter(new OpenLayers.LonLat(-45, -45), 4);
}
</script>
</head>
<body onload="init()">
<h1 id="title">Select Feature Test</h1>
<div id="map"></div>
<p>
The map includes two select feature controls. The first one operates on
geometries of type OpenLayers.Geometry.Point only and works on clicks. The
second one operates on geometries of type OpenLayers.Geometry.Polygon and
works on mouseover's. If you select the point geometry by clicking on it,
it shouldn't be unselected when the mouse moves out if it.
</p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Select Feature Test</title>
<style type="text/css">
body {
font-size: 0.8em;
}
p {
padding-top: 1em;
}
#map {
margin: 1em;
width: 512px;
height: 512px;
}
</style>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map, selectControl1, selectControl2;
function init() {
map = new OpenLayers.Map('map');
var wmsLayer = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'}
);
var vectorLayer = new OpenLayers.Layer.Vector("Vector Layer");
var pointFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(-50, -45)
);
var polygonFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon([
new OpenLayers.Geometry.LinearRing([
new OpenLayers.Geometry.Point(-50,-50),
new OpenLayers.Geometry.Point(-40,-50),
new OpenLayers.Geometry.Point(-40,-40),
new OpenLayers.Geometry.Point(-50,-50)
])
])
);
vectorLayer.addFeatures([pointFeature, polygonFeature]);
map.addLayers([wmsLayer, vectorLayer]);
selectControl1 = new OpenLayers.Control.SelectFeature(
vectorLayer, {geometryTypes: ['OpenLayers.Geometry.Point']}
);
selectControl2 = new OpenLayers.Control.SelectFeature(
vectorLayer, {
geometryTypes: ['OpenLayers.Geometry.Polygon'],
hover: true
});
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(selectControl1);
map.addControl(selectControl2);
selectControl1.activate();
selectControl2.activate();
map.setCenter(new OpenLayers.LonLat(-45, -45), 4);
}
</script>
</head>
<body onload="init()">
<h1 id="title">Select Feature Test</h1>
<div id="map"></div>
<p>
The map includes two select feature controls. The first one operates on
geometries of type OpenLayers.Geometry.Point only and works on clicks. The
second one operates on geometries of type OpenLayers.Geometry.Polygon and
works on mouseover's. If you select the point geometry by clicking on it,
it shouldn't be unselected when the mouse moves out if it.
</p>
</body>
</html>