Move vector code out of the way

This commit is contained in:
Tom Payne
2013-11-06 16:40:26 +01:00
parent 81349d382b
commit 4e65fefc00
271 changed files with 881 additions and 0 deletions

View File

@@ -1,59 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Draw features example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Draw features example</h4>
<p id="shortdesc">Example of using the Draw interaction.</p>
<form class="form-inline">
<label>Geometry type &nbsp;</label>
<select id="type">
<option value="polygon">Polygon</option>
<option value="linestring">Linestring</option>
<option value="point">Point</option>
</select>
</form>
<div id="docs">
<p>See the <a href="draw-features.js" target="_blank">draw-features.js source</a> to see how this is done.</p>
</div>
<div id="tags">draw, edit, vector</div>
</div>
</div>
</div>
<script src="loader.js?id=draw-features" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,122 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.interaction');
goog.require('ol.interaction.Draw');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Rule');
goog.require('ol.style.Shape');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({parser: null}),
style: new ol.style.Style({
rules: [
new ol.style.Rule({
filter: 'renderIntent("selected")',
symbolizers: [
new ol.style.Shape({
fill: new ol.style.Fill({
color: '#0099ff',
opacity: 1
}),
stroke: new ol.style.Stroke({
color: 'white',
opacity: 0.75
}),
size: 14
}),
new ol.style.Fill({
color: '#ffffff',
opacity: 0.5
}),
new ol.style.Stroke({
color: 'white',
width: 5
}),
new ol.style.Stroke({
color: '#0099ff',
width: 3
})
]
}),
new ol.style.Rule({
filter: 'renderIntent("temporary")',
symbolizers: [
new ol.style.Shape({
fill: new ol.style.Fill({
color: '#0099ff',
opacity: 1
}),
stroke: new ol.style.Stroke({
color: 'white',
opacity: 0.75
}),
size: 14,
zIndex: 1
})
]
})
],
symbolizers: [
new ol.style.Shape({
fill: new ol.style.Fill({
color: '#ffcc33',
opacity: 1
}),
size: 14
}),
new ol.style.Fill({
color: 'white',
opacity: 0.2
}),
new ol.style.Stroke({
color: '#ffcc33',
width: 2
})
]
})
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [-11000000, 4600000],
zoom: 4
})
});
var typeSelect = document.getElementById('type');
var draw; // global so we can remove it later
function addInteraction() {
draw = new ol.interaction.Draw({
layer: vector,
type: /** @type {ol.geom.GeometryType} */
(typeSelect.options[typeSelect.selectedIndex].value)
});
map.addInteraction(draw);
}
/**
* Let user change the geometry type.
* @param {Event} e Change event.
*/
typeSelect.onchange = function(e) {
map.removeInteraction(draw);
addInteraction();
};
addInteraction();

View File

@@ -1,55 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Get feature info example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<h4 id="title">GetFeatureInfo example</h4>
<p id="shortdesc">Example of a WMS layer and a vector layer, both configured to provide feature information on click.</p>
<div id="docs">
<p>See the <a href="getfeatureinfo.js" target="_blank">getfeatureinfo.js source</a> to see how this is done.</p>
</div>
<div id="tags">getfeatureinfo</div>
</div>
<div class="span4 offset4">
<div id="info" class="alert alert-success">
&nbsp;
</div>
</div>
</div>
</div>
<script src="loader.js?id=getfeatureinfo" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,56 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.source.TileWMS');
goog.require('ol.source.Vector');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var wms = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
params: {'LAYERS': 'ne:ne'}
})
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.GeoJSON(),
url: 'data/countries.geojson'
}),
style: new ol.style.Style({
symbolizers: [
new ol.style.Stroke({
color: '#33cc66',
width: 2
})
]
}),
transformFeatureInfo: function(features) {
return features.length > 0 ?
features[0].getId() + ': ' + features[0].get('name') : '&nbsp;';
}
});
var map = new ol.Map({
layers: [wms, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 1
})
});
map.on('singleclick', function(evt) {
map.getFeatureInfo({
pixel: evt.getPixel(),
success: function(featureInfoByLayer) {
document.getElementById('info').innerHTML = featureInfoByLayer.join('');
}
});
});

View File

@@ -1,50 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>GML example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">GML example</h4>
<p id="shortdesc">Example of using the GML parser.</p>
<div id="docs">
<p>See the <a href="gml.js" target="_blank">gml.js source</a> to see how this is done.</p>
</div>
<div id="tags">GML</div>
</div>
</div>
</div>
<script src="loader.js?id=gml" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,43 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.ogc.GML_v3');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.ogc.GML_v3(),
url: 'data/gml/topp-states-wfs.xml'
}),
style: new ol.style.Style({
symbolizers: [
new ol.style.Fill({
color: '#ffffff',
opacity: 0.25
}),
new ol.style.Stroke({
color: '#6666ff'
})
]
})
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [-10997171, 4658434],
zoom: 4
})
});

View File

@@ -1,55 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>GPX example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<h4 id="title">GPX example</h4>
<p id="shortdesc">Example of using the GPX parser.</p>
<div id="docs">
<p>See the <a href="gpx.js" target="_blank">gpx.js source</a> to see how this is done.</p>
</div>
<div id="tags">GPX</div>
</div>
<div class="span4 offset4">
<div id="info" class="alert alert-success">
&nbsp;
</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="loader.js?id=gpx" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,54 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GPX');
goog.require('ol.source.OSM');
goog.require('ol.source.Vector');
var raster = new ol.layer.Tile({
source: new ol.source.OSM()
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.GPX(),
url: 'data/gpx/yahoo.xml'
})
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [-7916461.9312699, 5226343.9091441],
zoom: 11
})
});
var displayFeatureInfo = function(pixel) {
map.getFeatures({
pixel: pixel,
layers: [vector],
success: function(featuresByLayer) {
var features = featuresByLayer[0];
var info = [];
for (var i = 0, ii = features.length; i < ii; ++i) {
info.push(features[i].get('name') + ': ' + features[i].get('type'));
}
document.getElementById('info').innerHTML = info.join(', ') || '&nbsp;';
}
});
};
$(map.getViewport()).on('mousemove', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
var pixel = evt.getPixel();
displayFeatureInfo(pixel);
});

View File

@@ -1,62 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Vector Icon Example</title>
<style>
#map {
position: relative;
}
#popup {
padding-bottom: 45px;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map">
<div id="popup"></div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Icon example</h4>
<p id="shortdesc">Example using an icon to symbolize a point.</p>
<div id="docs">
<p>See the <a href="icon.js" target="_blank">icon.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector, style, icon, marker, popup</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="loader.js?id=icon" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,95 +0,0 @@
goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.OverlayPositioning');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.source.TileJSON');
goog.require('ol.source.Vector');
goog.require('ol.style.Icon');
goog.require('ol.style.Style');
var raster = new ol.layer.Tile({
source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/mapbox.geography-class.jsonp'
})
});
var data = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
properties: {
name: 'Null Island',
population: 4000,
rainfall: 500
},
geometry: {
type: 'Point',
coordinates: [0, 0]
}
}]
};
var style = new ol.style.Style({
symbolizers: [
new ol.style.Icon({
url: 'data/icon.png',
yOffset: -22
})
]
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.GeoJSON(),
data: data
}),
style: style
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 3
})
});
var element = document.getElementById('popup');
var popup = new ol.Overlay({
element: element,
positioning: ol.OverlayPositioning.BOTTOM_CENTER,
stopEvent: false
});
map.addOverlay(popup);
map.on('singleclick', function(evt) {
map.getFeatures({
pixel: evt.getPixel(),
layers: [vector],
success: function(layerFeatures) {
var feature = layerFeatures[0][0];
if (feature) {
var geometry = feature.getGeometry();
var coord = geometry.getCoordinates();
popup.setPosition(coord);
$(element).popover({
'placement': 'top',
'html': true,
'content': feature.get('name')
});
$(element).popover('show');
} else {
$(element).popover('destroy');
}
}
});
});

View File

@@ -1,75 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Earthquakes in KML</title>
<style>
#map {
position: relative;
}
#info {
position: absolute;
height: 1px;
width: 1px;
z-index: 100;
}
.tooltip.in {
opacity: 1;
filter: alpha(opacity=100);
}
.tooltip.top .tooltip-arrow {
border-top-color: white;
}
.tooltip-inner {
border: 2px solid white;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"><div id="info"></div></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Earthquakes in KML</h4>
<p id="shortdesc">Demonstrates the use of a Shape symbolizer to render earthquake locations.</p>
<div id="docs">
<p>
This example parses a KML file and renders the features as a vector layer. The layer is given a <code>ol.style.Style</code> that renders earthquake locations with a size relative to their magnitude. The style uses a <code>ol.style.Shape</code> symbolizer where the <code>size</code> comes from the <code>magnitude</code> attribute on the features.
</p>
<p>See the <a href="kml-earthquakes.js" target="_blank">kml-earthquakes.js source</a> to see how this is done.</p>
</div>
<div id="tags">KML, vector, style</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="loader.js?id=kml-earthquakes" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,93 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.expr');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.KML');
goog.require('ol.source.Stamen');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Shape');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var style = new ol.style.Style({
symbolizers: [
new ol.style.Shape({
size: ol.expr.parse('5 + 20 * (magnitude - 5)'),
fill: new ol.style.Fill({
color: '#ff9900',
opacity: 0.4
}),
stroke: new ol.style.Stroke({
color: '#ffcc00',
opacity: 0.2
})
})
]
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.KML(),
url: 'data/kml/2012_Earthquakes_Mag5.kml'
}),
style: style
});
var raster = new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'toner'
})
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 2
})
});
var info = $('#info');
info.tooltip({
animation: false,
trigger: 'manual'
});
var displayFeatureInfo = function(pixel) {
info.css({
left: pixel[0] + 'px',
top: (pixel[1] - 15) + 'px'
});
map.getFeatures({
pixel: pixel,
layers: [vector],
success: function(layerFeatures) {
var feature = layerFeatures[0][0];
if (feature) {
info.tooltip('hide')
.attr('data-original-title', feature.get('name'))
.tooltip('fixTitle')
.tooltip('show');
} else {
info.tooltip('hide');
}
}
});
};
$(map.getViewport()).on('mousemove', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
var pixel = evt.getPixel();
displayFeatureInfo(pixel);
});

View File

@@ -1,63 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Timezones in KML</title>
<style>
#map {
position: relative;
}
#info {
position: absolute;
height: 1px;
width: 1px;
z-index: 100;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"><div id="info"></div></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Timezones in KML</h4>
<p id="shortdesc">Demonstrates rendering timezones from KML.</p>
<div id="docs">
<p>This example parses a KML file and renders the features as a vector layer. The layer is given a <code>ol.style.Style</code> that fills timezones yellow with an opacity calculated based on the current offset to local noon.</p>
<p>See the <a href="kml-timezones.js" target="_blank">kml-timezones.js source</a> to see how this is done.</p>
</div>
<div id="tags">KML, vector, style</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="loader.js?id=kml-timezones" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,115 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.expr');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.KML');
goog.require('ol.source.Stamen');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
/**
* Register a function to be used in a symbolizer. Here we want the opacity
* of polygons to be based on the offset from local noon. For example, a
* timezone where it is currently noon would have an opacity of 0.75. And a
* timezone where it is currently midnight would have an opacity of 0. This
* doesn't account for daylight savings, so don't use it to plan your vacation.
*/
ol.expr.register('getOpacity', function() {
var feature = this;
var offset = 0;
var name = feature.get('name'); // e.g. GMT -08:30
var match = name.match(/([-+]\d{2}):(\d{2})$/);
if (match) {
var hours = parseInt(match[1], 10);
var minutes = parseInt(match[2], 10);
offset = 60 * hours + minutes;
}
var date = new Date();
var local = new Date(date.getTime() +
(date.getTimezoneOffset() + offset) * 60000);
// offset from local noon (in hours)
var delta = Math.abs(12 - local.getHours() + (local.getMinutes() / 60));
if (delta > 12) {
delta = 24 - delta;
}
return 0.75 * (1 - delta / 12);
});
var style = new ol.style.Style({
symbolizers: [
new ol.style.Fill({
color: '#ffff33',
opacity: ol.expr.parse('getOpacity()')
}),
new ol.style.Stroke({
color: '#ffffff'
})
]
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.KML(),
url: 'data/kml/timezones.kml'
}),
style: style
});
var raster = new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'toner'
})
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 2
})
});
var info = $('#info');
info.tooltip({
animation: false,
trigger: 'manual'
});
var displayFeatureInfo = function(pixel) {
info.css({
left: pixel[0] + 'px',
top: (pixel[1] - 15) + 'px'
});
map.getFeatures({
pixel: pixel,
layers: [vector],
success: function(layerFeatures) {
var feature = layerFeatures[0][0];
if (feature) {
info.tooltip('hide')
.attr('data-original-title', feature.get('name'))
.tooltip('fixTitle')
.tooltip('show');
} else {
info.tooltip('hide');
}
}
});
};
$(map.getViewport()).on('mousemove', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
var pixel = evt.getPixel();
displayFeatureInfo(pixel);
});

View File

@@ -1,56 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>KML example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<h4 id="title">KML example</h4>
<p id="shortdesc">Example of using the KML parser.</p>
<div id="docs">
<p>See the <a href="kml.js" target="_blank">kml.js source</a> to see how this is done.</p>
</div>
<div id="tags">KML</div>
</div>
<div class="span4 offset4">
<div id="info" class="alert alert-success">
&nbsp;
</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="loader.js?id=kml" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,65 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.KML');
goog.require('ol.source.TileWMS');
goog.require('ol.source.Vector');
var raster = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://vmap0.tiles.osgeo.org/wms/vmap0',
crossOrigin: null,
params: {
'LAYERS': 'basic',
'VERSION': '1.1.1',
'FORMAT': 'image/jpeg'
}
})
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.KML({
maxDepth: 1, extractStyles: true, extractAttributes: true
}),
url: 'data/kml/lines.kml'
})
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
projection: 'EPSG:4326',
center: [-112.169, 36.099],
zoom: 11
})
});
var displayFeatureInfo = function(pixel) {
map.getFeatures({
pixel: pixel,
layers: [vector],
success: function(featuresByLayer) {
var features = featuresByLayer[0];
var info = [];
for (var i = 0, ii = features.length; i < ii; ++i) {
info.push(features[i].get('name'));
}
document.getElementById('info').innerHTML = info.join(', ') || '&nbsp';
}
});
};
$(map.getViewport()).on('mousemove', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
var pixel = evt.getPixel();
displayFeatureInfo(pixel);
});

View File

@@ -1,50 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Modify features example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Modify features example</h4>
<p id="shortdesc">Example of using the Modify interaction. Select a feature and drag the circle that appears when the cursor gets close to the selected geometry.</p>
<div id="docs">
<p>See the <a href="modify-features.js" target="_blank">modify-features.js source</a> to see how this is done.</p>
</div>
<div id="tags">modify, edit, vector</div>
</div>
</div>
</div>
<script src="loader.js?id=modify-features" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,108 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.interaction');
goog.require('ol.interaction.Modify');
goog.require('ol.interaction.Select');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.ogc.GML_v3');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Rule');
goog.require('ol.style.Shape');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
});
var vector = new ol.layer.Vector({
id: 'vector',
source: new ol.source.Vector({
parser: new ol.parser.ogc.GML_v3(),
url: 'data/gml/topp-states-wfs.xml'
}),
style: new ol.style.Style({
rules: [
new ol.style.Rule({
filter: 'renderIntent("selected")',
symbolizers: [
new ol.style.Fill({
color: '#ffffff',
opacity: 0.2
}),
new ol.style.Stroke({
color: 'white',
width: 5
}),
new ol.style.Stroke({
color: '#0099ff',
width: 3
})
]
}),
new ol.style.Rule({
filter: 'renderIntent("temporary")',
symbolizers: [
new ol.style.Shape({
fill: new ol.style.Fill({
color: '#0099ff',
opacity: 1
}),
stroke: new ol.style.Stroke({
color: 'white',
opacity: 0.75
}),
size: 14,
zIndex: 1
})
]
}),
new ol.style.Rule({
filter: 'renderIntent("future")',
symbolizers: [
new ol.style.Shape({
fill: new ol.style.Fill({
color: '#00ff33',
opacity: 1
}),
stroke: new ol.style.Stroke({
color: 'white',
opacity: 0.75
}),
size: 14,
zIndex: 1
})
]
})
],
symbolizers: [
new ol.style.Fill({
color: '#ffffff',
opacity: 0.1
}),
new ol.style.Stroke({
color: '#ffcc33',
width: 2
})
]
})
});
var select = new ol.interaction.Select();
var modify = new ol.interaction.Modify();
var map = new ol.Map({
interactions: ol.interaction.defaults().extend([select, modify]),
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [-11000000, 4600000],
zoom: 4
})
});

View File

@@ -1,50 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Select features example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Select features example</h4>
<p id="shortdesc">Example of using the Select interaction. Select features by clicking polygons. Hold the Shift-key to add to the selection.</p>
<div id="docs">
<p>See the <a href="select-features.js" target="_blank">select-features.js source</a> to see how this is done.</p>
</div>
<div id="tags">select, vector</div>
</div>
</div>
</div>
<script src="loader.js?id=select-features" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,61 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.interaction');
goog.require('ol.interaction.Select');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.ogc.GML_v3');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Rule');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
});
var vector = new ol.layer.Vector({
id: 'vector',
source: new ol.source.Vector({
parser: new ol.parser.ogc.GML_v3(),
url: 'data/gml/topp-states-wfs.xml'
}),
style: new ol.style.Style({
rules: [
new ol.style.Rule({
filter: 'renderIntent("selected")',
symbolizers: [
new ol.style.Fill({
color: '#ffffff',
opacity: 0.5
})
]
})
],
symbolizers: [
new ol.style.Fill({
color: '#ffffff',
opacity: 0.25
}),
new ol.style.Stroke({
color: '#6666ff'
})
]
})
});
var select = new ol.interaction.Select();
var map = new ol.Map({
interactions: ol.interaction.defaults().extend([select]),
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [-11000000, 4600000],
zoom: 4
})
});

View File

@@ -1,50 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Style with rules example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Style with rules example</h4>
<p id="shortdesc">Draws features with rule based styles.</p>
<div id="docs">
<p>See the <a href="style-rules.js" target="_blank">style-rules.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector, geojson, style</div>
</div>
</div>
</div>
<script src="loader.js?id=style-rules" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,181 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.control');
goog.require('ol.expr');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.proj');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Rule');
goog.require('ol.style.Shape');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.style.Text');
var style = new ol.style.Style({rules: [
new ol.style.Rule({
filter: 'where == "outer"',
symbolizers: [
new ol.style.Stroke({
color: ol.expr.parse('color'),
width: 4,
opacity: 1,
zIndex: 1
})
]
}),
new ol.style.Rule({
filter: 'where == "inner"',
symbolizers: [
new ol.style.Stroke({
color: '#013',
width: 4,
opacity: 1
}),
new ol.style.Stroke({
color: ol.expr.parse('color'),
width: 2,
opacity: 1
})
]
}),
new ol.style.Rule({
filter: 'geometryType("point")',
symbolizers: [
new ol.style.Shape({
size: 40,
fill: new ol.style.Fill({color: '#013'})
}),
new ol.style.Text({
color: '#bada55',
text: ol.expr.parse('label'),
fontFamily: 'Calibri,sans-serif',
fontSize: 14
})
]
})
]});
var vector = new ol.layer.Vector({
style: style,
source: new ol.source.Vector({
data: {
'type': 'FeatureCollection',
'features': [{
'type': 'Feature',
'properties': {
'color': '#BADA55',
'where': 'inner'
},
'geometry': {
'type': 'LineString',
'coordinates': [[-10000000, -10000000], [10000000, 10000000]]
}
}, {
'type': 'Feature',
'properties': {
'color': '#BADA55',
'where': 'inner'
},
'geometry': {
'type': 'LineString',
'coordinates': [[-10000000, 10000000], [10000000, -10000000]]
}
}, {
'type': 'Feature',
'properties': {
'color': '#013',
'where': 'outer'
},
'geometry': {
'type': 'LineString',
'coordinates': [[-10000000, -10000000], [-10000000, 10000000]]
}
}, {
'type': 'Feature',
'properties': {
'color': '#013',
'where': 'outer'
},
'geometry': {
'type': 'LineString',
'coordinates': [[-10000000, 10000000], [10000000, 10000000]]
}
}, {
'type': 'Feature',
'properties': {
'color': '#013',
'where': 'outer'
},
'geometry': {
'type': 'LineString',
'coordinates': [[10000000, 10000000], [10000000, -10000000]]
}
}, {
'type': 'Feature',
'properties': {
'color': '#013',
'where': 'outer'
},
'geometry': {
'type': 'LineString',
'coordinates': [[10000000, -10000000], [-10000000, -10000000]]
}
}, {
'type': 'Feature',
'properties': {
'label': 'South'
},
'geometry': {
'type': 'Point',
'coordinates': [0, -6000000]
}
}, {
'type': 'Feature',
'properties': {
'label': 'West'
},
'geometry': {
'type': 'Point',
'coordinates': [-6000000, 0]
}
}, {
'type': 'Feature',
'properties': {
'label': 'North'
},
'geometry': {
'type': 'Point',
'coordinates': [0, 6000000]
}
}, {
'type': 'Feature',
'properties': {
'label': 'East'
},
'geometry': {
'type': 'Point',
'coordinates': [6000000, 0]
}
}]
},
parser: new ol.parser.GeoJSON(),
projection: ol.proj.get('EPSG:3857')
})
});
var map = new ol.Map({
layers: [vector],
controls: ol.control.defaults({
attribution: false
}),
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 1
})
});

View File

@@ -1,50 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Synthetic data example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Synthetic data example</h4>
<p id="shortdesc">Synthetic data example.</p>
<div id="docs">
<p>See the <a href="synthetic-data.js" target="_blank">synthetic-data.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector</div>
</div>
</div>
</div>
<script src="loader.js?id=synthetic-data" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,80 +0,0 @@
goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.expr');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.proj');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Rule');
goog.require('ol.style.Shape');
goog.require('ol.style.ShapeType');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
});
// build up some GeoJSON features
var count = 20000;
var features = new Array(count);
var e = 18000000;
for (var i = 0; i < count; ++i) {
features[i] = {
type: 'Feature',
properties: {
i: i,
size: i % 2 ? 10 : 20
},
geometry: {
type: 'Point',
coordinates: [
2 * e * Math.random() - e, 2 * e * Math.random() - e
]
}
};
}
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
projection: ol.proj.get('EPSG:3857'),
parser: new ol.parser.GeoJSON(),
data: {
type: 'FeatureCollection',
features: features
}
}),
style: new ol.style.Style({rules: [
new ol.style.Rule({
symbolizers: [
new ol.style.Shape({
type: ol.style.ShapeType.CIRCLE,
size: ol.expr.parse('size'),
stroke: new ol.style.Stroke({color: '#666666'}),
fill: new ol.style.Fill({color: '#bada55'})
})
]
})
]})
});
var popup = new ol.Overlay({
element: document.getElementById('popup')
});
var map = new ol.Map({
layers: [vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 2
}),
overlays: [popup]
});

View File

@@ -1,51 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>TopoJSON Example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span8">
<h4 id="title">TopoJSON example</h4>
<p id="shortdesc">Demonstrates rendering of features from a TopoJSON topology.</p>
<div id="docs">
<p>See the <a href="topojson.js" target="_blank">topojson.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector, topojson, style</div>
</div>
<div id="info" class="span4">&nbsp;</div>
</div>
</div>
<script src="loader.js?id=topojson" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,48 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.TopoJSON');
goog.require('ol.source.TileJSON');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var raster = new ol.layer.Tile({
source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/mapbox.world-dark.jsonp'
})
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'data/topojson/world-110m.json',
parser: new ol.parser.TopoJSON()
}),
style: new ol.style.Style({
symbolizers: [
new ol.style.Fill({
color: '#BADA55',
opacity: 0.5
}),
new ol.style.Stroke({
color: '#FFF',
opacity: 1,
width: 1.5
})
]
})
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 1
})
});

View File

@@ -1,56 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Vector layer example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<h4 id="title">Vector layer example</h4>
<p id="shortdesc">Example of a countries vector layer with country information on hover and country labels at higher zoom levels.</p>
<div id="docs">
<p>See the <a href="vector-layer.js" target="_blank">vector-layer.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector, geojson, style</div>
</div>
<div class="span4 offset4">
<div id="info" class="alert alert-success">
&nbsp;
</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="loader.js?id=vector-layer" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,88 +0,0 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.expr');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Rule');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.style.Text');
var raster = new ol.layer.Tile({
source: new ol.source.MapQuestOpenAerial()
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.GeoJSON(),
url: 'data/countries.geojson'
}),
style: new ol.style.Style({rules: [
new ol.style.Rule({
symbolizers: [
new ol.style.Fill({
color: 'white',
opacity: 0.6
}),
new ol.style.Stroke({
color: '#319FD3',
opacity: 1
})
]
}),
new ol.style.Rule({
maxResolution: 5000,
symbolizers: [
new ol.style.Text({
color: 'black',
text: ol.expr.parse('name'),
fontFamily: 'Calibri,sans-serif',
fontSize: 12,
stroke: new ol.style.Stroke({
color: 'white',
width: 3
})
})
]
})
]})
});
var map = new ol.Map({
layers: [raster, vector],
renderer: ol.RendererHint.CANVAS,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 1
})
});
var displayFeatureInfo = function(pixel) {
map.getFeatures({
pixel: pixel,
layers: [vector],
success: function(featuresByLayer) {
var features = featuresByLayer[0];
document.getElementById('info').innerHTML = features.length > 0 ?
features[0].getId() + ': ' + features[0].get('name') :
'&nbsp;';
}
});
};
$(map.getViewport()).on('mousemove', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
var pixel = evt.getPixel();
displayFeatureInfo(pixel);
});