Use ol.source.GeoJSON in icon example
This commit is contained in:
+18
-23
@@ -3,12 +3,11 @@ goog.require('ol.Overlay');
|
|||||||
goog.require('ol.OverlayPositioning');
|
goog.require('ol.OverlayPositioning');
|
||||||
goog.require('ol.RendererHint');
|
goog.require('ol.RendererHint');
|
||||||
goog.require('ol.View2D');
|
goog.require('ol.View2D');
|
||||||
goog.require('ol.format.GeoJSON');
|
|
||||||
goog.require('ol.icon');
|
goog.require('ol.icon');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
|
goog.require('ol.source.GeoJSON');
|
||||||
goog.require('ol.source.TileJSON');
|
goog.require('ol.source.TileJSON');
|
||||||
goog.require('ol.source.Vector');
|
|
||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
|
|
||||||
|
|
||||||
@@ -18,32 +17,28 @@ var raster = new ol.layer.Tile({
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
var features = new ol.format.GeoJSON().readFeatures({
|
|
||||||
'type': 'FeatureCollection',
|
|
||||||
'features': [{
|
|
||||||
'type': 'Feature',
|
|
||||||
'properties': {
|
|
||||||
'name': 'Null Island',
|
|
||||||
'population': 4000,
|
|
||||||
'rainfall': 500
|
|
||||||
},
|
|
||||||
'geometry': {
|
|
||||||
'type': 'Point',
|
|
||||||
'coordinates': [0, 0]
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
var vectorSource = new ol.source.Vector({
|
|
||||||
features: features
|
|
||||||
});
|
|
||||||
|
|
||||||
var styleArray = [new ol.style.Style({
|
var styleArray = [new ol.style.Style({
|
||||||
image: ol.icon.renderIcon('data/icon.png')
|
image: ol.icon.renderIcon('data/icon.png')
|
||||||
})];
|
})];
|
||||||
|
|
||||||
var vector = new ol.layer.Vector({
|
var vector = new ol.layer.Vector({
|
||||||
source: vectorSource,
|
source: new ol.source.GeoJSON(/** @type {ol.source.GeoJSONOptions} */ ({
|
||||||
|
object: {
|
||||||
|
'type': 'FeatureCollection',
|
||||||
|
'features': [{
|
||||||
|
'type': 'Feature',
|
||||||
|
'properties': {
|
||||||
|
'name': 'Null Island',
|
||||||
|
'population': 4000,
|
||||||
|
'rainfall': 500
|
||||||
|
},
|
||||||
|
'geometry': {
|
||||||
|
'type': 'Point',
|
||||||
|
'coordinates': [0, 0]
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
})),
|
||||||
styleFunction: function(feature, resolution) {
|
styleFunction: function(feature, resolution) {
|
||||||
return styleArray;
|
return styleArray;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user