[OpenLayers-Users] OpenLayers.Protocol.Script with JSON
Morescratch
morescratch at live.com
Wed Feb 6 07:02:21 PST 2013
Hi all I have tried everything to try and get a remote JSON file into my map.
Here is my code:
var olLayer = new OpenLayers.Layer.Vector(
'myJSON, {
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.Script({
url:
'http://earthquake.usgs.gov/earthquakes/feed/geojson/1.0/hour',
format: new OpenLayers.Format.GeoJSON(),
onFeatureInsert: function(feature) {
//do something
},
parseFeatures: function(data) {
//do something
}
})
})
Curiously (or not) the request for the feed doesn't happen when the map is
loaded, I have to switch the layer off then on again before the request is
sent. I can confirm that the feed is returned however.
Note I have stubbed out onFeatureInsert and parseFeatures because I need to
add some special sauce to my features before rendering them. Any pointers
would be appreciated!
Many thanks!
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/OpenLayers-Protocol-Script-with-JSON-tp5032497.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list