This is my code for displaying geojson in OpenLayers, where "geourl" is directed to a json file in Amazon S3.
geojson_layer = new OpenLayers.Layer.Vector("GeoJSON", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url:geourl,
format: new OpenLayers.Format.GeoJSON()})
});
But I received the error like this:
> Failed to load resource: the server responded with a status of 403
> (Forbidden) "geourl" Failed to load resource: No
> 'Access-Control-Allow-Origin' header is present on the requested
> resource. Origin 'http://localhost:8081' is therefore not allowed
> access. "geourl" XMLHttpRequest cannot load "geourl" No
> 'Access-Control-Allow-Origin' header is present on the requested
> resource. Origin 'http://localhost:8081' is therefore not allowed
> access.
Nothing changed when I added
self.response.headers.add_header("Access-Control-Allow-Origin", "*")
to my webapp RequestHandler Class.
GeoJSONOptions
class. Not sure what that means, though.