Merge pull request #1454 from twpayne/vector-api-vector-file-urls
[vector-api] Add urls option to ol.source.VectorFile
This commit is contained in:
@@ -2,27 +2,17 @@ goog.require('ol.Attribution');
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.RendererHint');
|
goog.require('ol.RendererHint');
|
||||||
goog.require('ol.View2D');
|
goog.require('ol.View2D');
|
||||||
goog.require('ol.format.IGC');
|
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
goog.require('ol.geom.Point');
|
goog.require('ol.geom.Point');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.source.IGC');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
goog.require('ol.source.Vector');
|
|
||||||
goog.require('ol.style.Circle');
|
goog.require('ol.style.Circle');
|
||||||
goog.require('ol.style.Stroke');
|
goog.require('ol.style.Stroke');
|
||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
var tracklogs = [
|
|
||||||
'data/igc/Clement-Latour.igc',
|
|
||||||
'data/igc/Damien-de-Baenst.igc',
|
|
||||||
'data/igc/Sylvain-Dhonneur.igc',
|
|
||||||
'data/igc/Tom-Payne.igc',
|
|
||||||
'data/igc/Ulrich-Prinz.igc'
|
|
||||||
];
|
|
||||||
|
|
||||||
var colors = {
|
var colors = {
|
||||||
'Clement Latour': 'rgba(0, 0, 255, 0.7)',
|
'Clement Latour': 'rgba(0, 0, 255, 0.7)',
|
||||||
'Damien de Baesnt': 'rgba(0, 215, 255, 0.7)',
|
'Damien de Baesnt': 'rgba(0, 215, 255, 0.7)',
|
||||||
@@ -47,7 +37,15 @@ var styleFunction = function(feature, resolution) {
|
|||||||
return styleArray;
|
return styleArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
var vectorSource = new ol.source.Vector();
|
var vectorSource = new ol.source.IGC({
|
||||||
|
urls: [
|
||||||
|
'data/igc/Clement-Latour.igc',
|
||||||
|
'data/igc/Damien-de-Baenst.igc',
|
||||||
|
'data/igc/Sylvain-Dhonneur.igc',
|
||||||
|
'data/igc/Tom-Payne.igc',
|
||||||
|
'data/igc/Ulrich-Prinz.igc'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
@@ -77,18 +75,6 @@ var map = new ol.Map({
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var transform = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
|
|
||||||
var i, ii;
|
|
||||||
for (i = 0, ii = tracklogs.length; i < ii; ++i) {
|
|
||||||
$.get(tracklogs[i], function(data) {
|
|
||||||
var format = new ol.format.IGC();
|
|
||||||
var feature = format.readFeature(data);
|
|
||||||
feature.getGeometry().transform(transform);
|
|
||||||
vectorSource.addFeature(feature);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var point = null;
|
var point = null;
|
||||||
var line = null;
|
var line = null;
|
||||||
var displaySnap = function(coordinate) {
|
var displaySnap = function(coordinate) {
|
||||||
|
|||||||
@@ -527,6 +527,7 @@
|
|||||||
* @property {ol.proj.ProjectionLike} reprojectTo Re-project to.
|
* @property {ol.proj.ProjectionLike} reprojectTo Re-project to.
|
||||||
* @property {string|undefined} text Text.
|
* @property {string|undefined} text Text.
|
||||||
* @property {string|undefined} url URL.
|
* @property {string|undefined} url URL.
|
||||||
|
* @property {Array.<string>|undefined} urls URLs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -535,6 +536,7 @@
|
|||||||
* Possible values are `barometric`, `gps`, and `none`. Default is `none`.
|
* Possible values are `barometric`, `gps`, and `none`. Default is `none`.
|
||||||
* @property {string|undefined} text Text.
|
* @property {string|undefined} text Text.
|
||||||
* @property {string|undefined} url URL.
|
* @property {string|undefined} url URL.
|
||||||
|
* @property {Array.<string>|undefined} urls URLs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -567,6 +569,7 @@
|
|||||||
* @property {ol.proj.ProjectionLike} reprojectTo Re-project to.
|
* @property {ol.proj.ProjectionLike} reprojectTo Re-project to.
|
||||||
* @property {string|undefined} text Text.
|
* @property {string|undefined} text Text.
|
||||||
* @property {string|undefined} url URL.
|
* @property {string|undefined} url URL.
|
||||||
|
* @property {Array.<string>|undefined} urls URLs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -712,6 +715,7 @@
|
|||||||
* @property {ol.proj.ProjectionLike} projection Projection.
|
* @property {ol.proj.ProjectionLike} projection Projection.
|
||||||
* @property {string|undefined} text Text.
|
* @property {string|undefined} text Text.
|
||||||
* @property {string|undefined} url URL.
|
* @property {string|undefined} url URL.
|
||||||
|
* @property {Array.<string>|undefined} urls URLs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ ol.source.GeoJSON = function(opt_options) {
|
|||||||
projection: options.projection,
|
projection: options.projection,
|
||||||
reprojectTo: options.reprojectTo,
|
reprojectTo: options.reprojectTo,
|
||||||
text: options.text,
|
text: options.text,
|
||||||
url: options.url
|
url: options.url,
|
||||||
|
urls: options.urls
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ ol.source.IGC = function(opt_options) {
|
|||||||
altitudeMode: options.altitudeMode
|
altitudeMode: options.altitudeMode
|
||||||
}),
|
}),
|
||||||
text: options.text,
|
text: options.text,
|
||||||
url: options.url
|
url: options.url,
|
||||||
|
urls: options.urls
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ ol.source.KML = function(opt_options) {
|
|||||||
projection: options.projection,
|
projection: options.projection,
|
||||||
reprojectTo: options.reprojectTo,
|
reprojectTo: options.reprojectTo,
|
||||||
text: options.text,
|
text: options.text,
|
||||||
url: options.url
|
url: options.url,
|
||||||
|
urls: options.urls
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,9 +57,19 @@ ol.source.VectorFile = function(opt_options) {
|
|||||||
this.readFeatures_(options.text);
|
this.readFeatures_(options.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goog.isDef(options.url)) {
|
if (goog.isDef(options.url) || goog.isDef(options.urls)) {
|
||||||
this.setState(ol.source.State.LOADING);
|
this.setState(ol.source.State.LOADING);
|
||||||
goog.net.XhrIo.send(options.url, goog.bind(this.handleXhrIo_, this));
|
var handleXhrIo = goog.bind(this.handleXhrIo_, this);
|
||||||
|
if (goog.isDef(options.url)) {
|
||||||
|
goog.net.XhrIo.send(options.url, handleXhrIo);
|
||||||
|
}
|
||||||
|
if (goog.isDef(options.urls)) {
|
||||||
|
var urls = options.urls;
|
||||||
|
var i, ii;
|
||||||
|
for (i = 0, ii = urls.length; i < ii; ++i) {
|
||||||
|
goog.net.XhrIo.send(urls[i], handleXhrIo);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user