-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1744 from twpayne/remote-vector
ol.source.RemoteVector
- Loading branch information
Showing
30 changed files
with
897 additions
and
2,442 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!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>Tile vector 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" style="background: white;"></div> | ||
</div> | ||
</div> | ||
|
||
<div class="row-fluid"> | ||
|
||
<div class="span12"> | ||
<h4 id="title">Tile vector example</h4> | ||
<p id="shortdesc">Example of <a href="http://openstreetmap.us/~migurski/vector-datasource/">vector tiles from openstreetmap.us</a>.</p> | ||
<div id="docs"> | ||
<p>See the <a href="tile-vector.js" target="_blank">tile-vector.js source</a> to see how this is done.</p> | ||
</div> | ||
<div id="tags">tile-vector, openstreetmap</div> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<script src="jquery.min.js" type="text/javascript"></script> | ||
<script src="../resources/example-behaviour.js" type="text/javascript"></script> | ||
<script src="loader.js?id=tile-vector" type="text/javascript"></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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
goog.require('ol.Map'); | ||
goog.require('ol.View2D'); | ||
goog.require('ol.format.TopoJSON'); | ||
goog.require('ol.layer.Vector'); | ||
goog.require('ol.proj'); | ||
goog.require('ol.source.TileVector'); | ||
goog.require('ol.style.Fill'); | ||
goog.require('ol.style.Stroke'); | ||
goog.require('ol.style.Style'); | ||
goog.require('ol.tilegrid.XYZ'); | ||
|
||
var waterLayer = new ol.layer.Vector({ | ||
source: new ol.source.TileVector({ | ||
format: new ol.format.TopoJSON({ | ||
defaultProjection: 'EPSG:4326' | ||
}), | ||
projection: 'EPSG:3857', | ||
tileGrid: new ol.tilegrid.XYZ({ | ||
maxZoom: 19 | ||
}), | ||
url: 'http://{a-c}.tile.openstreetmap.us/' + | ||
'vectiles-water-areas/{z}/{x}/{y}.topojson' | ||
}), | ||
style: new ol.style.Style({ | ||
fill: new ol.style.Fill({ | ||
color: '#9db9e8' | ||
}) | ||
}) | ||
}); | ||
|
||
var roadStyleCache = {}; | ||
var roadLayer = new ol.layer.Vector({ | ||
source: new ol.source.TileVector({ | ||
format: new ol.format.TopoJSON({ | ||
defaultProjection: 'EPSG:4326' | ||
}), | ||
projection: 'EPSG:3857', | ||
tileGrid: new ol.tilegrid.XYZ({ | ||
maxZoom: 19 | ||
}), | ||
url: 'http://{a-c}.tile.openstreetmap.us/' + | ||
'vectiles-highroad/{z}/{x}/{y}.topojson' | ||
}), | ||
style: function(feature, resolution) { | ||
var kind = feature.get('kind'); | ||
var railway = feature.get('railway'); | ||
var sort_key = feature.get('sort_key'); | ||
var styleKey = kind + '/' + railway + '/' + sort_key; | ||
var styleArray = roadStyleCache[styleKey]; | ||
if (!styleArray) { | ||
var color, width; | ||
if (railway) { | ||
color = '#7de'; | ||
width = 1; | ||
} else { | ||
color = { | ||
'major_road': '#776', | ||
'minor_road': '#ccb', | ||
'highway': '#f39' | ||
}[kind]; | ||
width = kind == 'highway' ? 1.5 : 1; | ||
} | ||
styleArray = [new ol.style.Style({ | ||
stroke: new ol.style.Stroke({ | ||
color: color, | ||
width: width | ||
}), | ||
zIndex: sort_key | ||
})]; | ||
roadStyleCache[styleKey] = styleArray; | ||
} | ||
return styleArray; | ||
} | ||
}); | ||
|
||
var map = new ol.Map({ | ||
layers: [waterLayer, roadLayer], | ||
renderer: 'canvas', | ||
target: document.getElementById('map'), | ||
view: new ol.View2D({ | ||
center: ol.proj.transform([-74.0064, 40.7142], 'EPSG:4326', 'EPSG:3857'), | ||
maxZoom: 19, | ||
zoom: 14 | ||
}) | ||
}); |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@exportSymbol ol.format.OSMXML |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@exportSymbol ol.loadingstrategy.all | ||
@exportSymbol ol.loadingstrategy.bbox | ||
@exportSymbol ol.loadingstrategy.createTile |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
goog.provide('ol.loadingstrategy'); | ||
|
||
goog.require('ol.TileCoord'); | ||
|
||
|
||
/** | ||
* @param {ol.Extent} extent Extent. | ||
* @param {number} resolution Resolution. | ||
* @return {Array.<ol.Extent>} Extents. | ||
*/ | ||
ol.loadingstrategy.all = function(extent, resolution) { | ||
return [[-Infinity, -Infinity, Infinity, Infinity]]; | ||
}; | ||
|
||
|
||
/** | ||
* @param {ol.Extent} extent Extent. | ||
* @param {number} resolution Resolution. | ||
* @return {Array.<ol.Extent>} Extents. | ||
*/ | ||
ol.loadingstrategy.bbox = function(extent, resolution) { | ||
return [extent]; | ||
}; | ||
|
||
|
||
/** | ||
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid. | ||
* @return {function(ol.Extent, number): Array.<ol.Extent>} Loading strategy. | ||
*/ | ||
ol.loadingstrategy.createTile = function(tileGrid) { | ||
return ( | ||
/** | ||
* @param {ol.Extent} extent Extent. | ||
* @param {number} resolution Resolution. | ||
* @return {Array.<ol.Extent>} Extents. | ||
*/ | ||
function(extent, resolution) { | ||
var z = tileGrid.getZForResolution(resolution); | ||
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z); | ||
/** @type {Array.<ol.Extent>} */ | ||
var extents = []; | ||
var tileCoord = new ol.TileCoord(z, 0, 0); | ||
for (tileCoord.x = tileRange.minX; tileCoord.x <= tileRange.maxX; | ||
++tileCoord.x) { | ||
for (tileCoord.y = tileRange.minY; tileCoord.y <= tileRange.maxY; | ||
++tileCoord.y) { | ||
extents.push(tileGrid.getTileCoordExtent(tileCoord)); | ||
} | ||
} | ||
return extents; | ||
}); | ||
}; |
Oops, something went wrong.