Add TopoJSON source & use it in example

This commit is contained in:
Antoine Abt
2014-01-08 11:20:16 +01:00
parent 000e9ad82d
commit a69f62e238
3 changed files with 49 additions and 18 deletions

View File

@@ -3,9 +3,8 @@ 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.source.TopoJSON');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
@@ -17,24 +16,23 @@ var raster = new ol.layer.Tile({
})
});
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'data/topojson/world-110m.json',
parser: new ol.parser.TopoJSON()
var styleArray = [new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.6)'
}),
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
})
]
stroke: new ol.style.Stroke({
color: '#319FD3',
width: 1
})
})];
var vector = new ol.layer.Vector({
source: new ol.source.TopoJSON({
url: 'data/topojson/world-110m.json'
}),
styleFunction: function(feature, resolution) {
return styleArray;
}
});
var map = new ol.Map({

View File

@@ -0,0 +1 @@
@exportSymbol ol.source.TopoJSON

View File

@@ -0,0 +1,32 @@
goog.provide('ol.source.TopoJSON');
goog.require('ol.format.TopoJSON');
goog.require('ol.source.VectorFile');
/**
* @constructor
* @extends {ol.source.VectorFile}
* @param {olx.source.TopoJSONOptions=} opt_options Options.
*/
ol.source.TopoJSON = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
format: new ol.format.TopoJSON({
defaultProjection: options.defaultProjection
}),
logo: options.logo,
object: options.object,
projection: options.projection,
reprojectTo: options.reprojectTo,
text: options.text,
url: options.url
});
};
goog.inherits(ol.source.TopoJSON, ol.source.VectorFile);