Adding layer for generating dynamic point grids. r=bartvde (closes #3344)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12099 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
75
examples/point-grid.html
Normal file
75
examples/point-grid.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>OpenLayers Point Grid Example</title>
|
||||
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<style type="text/css">
|
||||
.olControlAttribution {
|
||||
left: 5px;
|
||||
bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="title">Point Grid Example</h1>
|
||||
|
||||
<div id="tags">
|
||||
point grid
|
||||
</div>
|
||||
|
||||
<div id="shortdesc">Use a PointGrid layer to display a grid of regularly spaced points</div>
|
||||
|
||||
<div id="map" class="smallmap"></div>
|
||||
|
||||
Grid rotation:
|
||||
<select name="rotation" id="rotation">
|
||||
<option value="-45">-45</option>
|
||||
<option value="-30">-30</option>
|
||||
<option value="-15">-15</option>
|
||||
<option value="0">0</option>
|
||||
<option value="15">15</option>
|
||||
<option value="30">30</option>
|
||||
<option value="45">45</option>
|
||||
</select>
|
||||
|
||||
|
||||
Grid spacing:
|
||||
<select name="dx" id="dx">
|
||||
<option value="10">10</option>
|
||||
<option value="15">15</option>
|
||||
<option value="20">20</option>
|
||||
<option value="25">25</option>
|
||||
<option value="30">30</option>
|
||||
</select> x
|
||||
<select name="dy" id="dy">
|
||||
<option value="10">10</option>
|
||||
<option value="15">15</option>
|
||||
<option value="20">20</option>
|
||||
<option value="25">25</option>
|
||||
<option value="30">30</option>
|
||||
</select>
|
||||
|
||||
|
||||
Max points:
|
||||
<select name="max" id="max">
|
||||
<option value="150">150</option>
|
||||
<option value="250">250</option>
|
||||
<option value="350">350</option>
|
||||
</select>
|
||||
|
||||
<div class="docs">
|
||||
<p>
|
||||
This example demonstrates a <code>OpenLayers.Layer.PointGrid</code>
|
||||
layer to render a regularly spaced grid of point features.
|
||||
</p><p>
|
||||
See the <a href="point-grid.js" target="_blank">
|
||||
point-grid.js source</a> to see how this is done.
|
||||
</p>
|
||||
</div>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="point-grid.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
33
examples/point-grid.js
Normal file
33
examples/point-grid.js
Normal file
@@ -0,0 +1,33 @@
|
||||
var points = new OpenLayers.Layer.PointGrid({
|
||||
isBaseLayer: true, dx: 15, dy: 15
|
||||
});
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
layers: [points],
|
||||
center: new OpenLayers.LonLat(0, 0),
|
||||
zoom: 2
|
||||
});
|
||||
|
||||
var rotation = document.getElementById("rotation");
|
||||
rotation.value = String(points.rotation);
|
||||
rotation.onchange = function() {
|
||||
points.setRotation(Number(rotation.value));
|
||||
}
|
||||
|
||||
var dx = document.getElementById("dx");
|
||||
var dy = document.getElementById("dy");
|
||||
dx.value = String(points.dx);
|
||||
dy.value = String(points.dy);
|
||||
dx.onchange = function() {
|
||||
points.setSpacing(Number(dx.value), Number(dy.value));
|
||||
}
|
||||
dy.onchange = function() {
|
||||
points.setSpacing(Number(dx.value), Number(dy.value));
|
||||
}
|
||||
|
||||
var max = document.getElementById("max");
|
||||
max.value = String(points.maxFeatures);
|
||||
max.onchange = function() {
|
||||
points.setMaxFeatures(Number(max.value));
|
||||
}
|
||||
78
examples/snap-grid.html
Normal file
78
examples/snap-grid.html
Normal file
@@ -0,0 +1,78 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>OpenLayers Snap Grid Example</title>
|
||||
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<style type="text/css">
|
||||
.olControlAttribution {
|
||||
left: 5px;
|
||||
bottom: 5px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlModifyFeatureItemInactive {
|
||||
background-position: -1px -1px;
|
||||
}
|
||||
.olControlEditingToolbar .olControlModifyFeatureItemActive {
|
||||
background-position: -1px -24px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="title">Snap Grid Example</h1>
|
||||
|
||||
<div id="tags">
|
||||
snap grid
|
||||
</div>
|
||||
|
||||
<div id="shortdesc">Use a PointGrid layer and a Snapping control to snap to a grid of regularly spaced points</div>
|
||||
|
||||
<div id="map" class="smallmap"></div>
|
||||
|
||||
Grid rotation:
|
||||
<select name="rotation" id="rotation">
|
||||
<option value="-45">-45</option>
|
||||
<option value="-30">-30</option>
|
||||
<option value="-15">-15</option>
|
||||
<option value="0">0</option>
|
||||
<option value="15">15</option>
|
||||
<option value="30">30</option>
|
||||
<option value="45">45</option>
|
||||
</select>
|
||||
|
||||
|
||||
Grid spacing:
|
||||
<select name="spacing" id="spacing">
|
||||
<option value="150">150</option>
|
||||
<option value="300">300</option>
|
||||
<option value="600">600</option>
|
||||
<option value="1200">1200</option>
|
||||
<option value="2400">2400</option>
|
||||
</select>
|
||||
|
||||
|
||||
Max points:
|
||||
<select name="max" id="max">
|
||||
<option value="150">150</option>
|
||||
<option value="250">250</option>
|
||||
<option value="350">350</option>
|
||||
</select>
|
||||
|
||||
<div class="docs">
|
||||
<p>
|
||||
This example demonstrates feature editing with snapping to a regular
|
||||
grid. The map is configured with a <code>OpenLayers.Layer.PointGrid</code>
|
||||
layer and a <code>OpenLayers.Control.Snapping</code> agent. For the
|
||||
best performance, the point grid layer should not made visible.
|
||||
Snapping still works with layers that are not visible.
|
||||
</p><p>
|
||||
See the <a href="snap-grid.js" target="_blank">
|
||||
snap-grid.js source</a> to see how this is done.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="snap-grid.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
81
examples/snap-grid.js
Normal file
81
examples/snap-grid.js
Normal file
@@ -0,0 +1,81 @@
|
||||
var points = new OpenLayers.Layer.PointGrid({
|
||||
name: "Snap Grid",
|
||||
dx: 600, dy: 600,
|
||||
styleMap: new OpenLayers.StyleMap({
|
||||
pointRadius: 1,
|
||||
strokeColor: "#3333ff",
|
||||
strokeWidth: 1,
|
||||
fillOpacity: 1,
|
||||
fillColor: "#ffffff",
|
||||
graphicName: "square"
|
||||
})
|
||||
});
|
||||
|
||||
var lines = new OpenLayers.Layer.Vector("Lines", {
|
||||
styleMap: new OpenLayers.StyleMap({
|
||||
pointRadius: 3,
|
||||
strokeColor: "#ff3300",
|
||||
strokeWidth: 3,
|
||||
fillOpacity: 0
|
||||
})
|
||||
});
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
layers: [new OpenLayers.Layer.OSM(), points, lines],
|
||||
controls: [
|
||||
new OpenLayers.Control.Navigation(),
|
||||
new OpenLayers.Control.LayerSwitcher(),
|
||||
new OpenLayers.Control.Attribution()
|
||||
],
|
||||
restrictedExtent: new OpenLayers.Bounds(
|
||||
1035374, 7448940, 1074510, 7468508
|
||||
),
|
||||
center: new OpenLayers.LonLat(1054942, 7458724),
|
||||
zoom: 13
|
||||
});
|
||||
|
||||
// configure the snapping agent
|
||||
var snap = new OpenLayers.Control.Snapping({
|
||||
layer: lines,
|
||||
targets: [{
|
||||
layer: points,
|
||||
tolerance: 15
|
||||
}]
|
||||
});
|
||||
snap.activate();
|
||||
|
||||
// add some editing tools to a panel
|
||||
var panel = new OpenLayers.Control.Panel({
|
||||
displayClass: "olControlEditingToolbar"
|
||||
});
|
||||
var draw = new OpenLayers.Control.DrawFeature(
|
||||
lines, OpenLayers.Handler.Path,
|
||||
{displayClass: "olControlDrawFeaturePath", title: "Draw Features"}
|
||||
);
|
||||
modify = new OpenLayers.Control.ModifyFeature(
|
||||
lines, {displayClass: "olControlModifyFeature", title: "Modify Features"}
|
||||
);
|
||||
panel.addControls([
|
||||
new OpenLayers.Control.Navigation({title: "Navigate"}),
|
||||
modify, draw
|
||||
]);
|
||||
map.addControl(panel);
|
||||
|
||||
var rotation = document.getElementById("rotation");
|
||||
rotation.value = String(points.rotation);
|
||||
rotation.onchange = function() {
|
||||
points.setRotation(Number(rotation.value));
|
||||
}
|
||||
|
||||
var spacing = document.getElementById("spacing");
|
||||
spacing.value = String(points.dx);
|
||||
spacing.onchange = function() {
|
||||
points.setSpacing(Number(spacing.value));
|
||||
}
|
||||
|
||||
var max = document.getElementById("max");
|
||||
max.value = String(points.maxFeatures);
|
||||
max.onchange = function() {
|
||||
points.setMaxFeatures(Number(max.value));
|
||||
}
|
||||
Reference in New Issue
Block a user