[OpenLayers-Users] Re: using Request.GET vs. Layer with strategy,
protocol, format
leopard01
leonardo.araque at gmail.com
Wed Apr 4 12:07:55 EDT 2012
Hello listers,
My objective is: Fetching the file source (GMLv3) hosted in a different
server to my local application.
I have a similar problem like this post .. but its no clear for my if Sccot
solved his problem yet,
and i really appreciate yours help.
Corresponding to the option A sended by Sccot :
>//A:
> var vector_layer = new OpenLayers.Layer.Vector("Stores");
> map.addLayer(vector_layer);
>
> OpenLayers.Request.GET({
> url: "/kiosks_status_geoJSON/",
> headers: {'Accept':'application/json'},
> success: function (req)
> {
> var g = new OpenLayers.Format.GeoJSON();
> var feature_collection = g.read(req.responseText);
> //console.log(feature_collection);
> vector_layer.destroyFeatures();
> vector_layer.addFeatures(feature_collection);
> }
> });
Im working with a GML.v3 format file, this file comes from another server
and is created with OGR2GOGR
specifications. The file is here:
http://200.85.231.185/sites/all/modules/sar/polygontheme.php?theme=trampas&user=7&plantacioncode=2040504
My problem is, most of the implementations runs his applications with
relative or absolute URLs to the
same machine ( or IP ) to the file source. But in my case, my application
run in a different IP that the file source.
Now my questions is, what is wrong with the next code ??.
var vector_layer = new OpenLayers.Layer.Vector("Layer_name");
map.addLayer(vector_layer);
OpenLayers.Request.GET({
url:
"http://200.85.231.185/sites/all/modules/sar/polygontheme.php?theme=trampas&user=7&plantacioncode=2040504",
headers: {'Accept':'application/xml'},
success: function (req)
{
var g = new OpenLayers.Format.GML.v3();
var feature_collection = g.read(req.responseXML);
//console.log(feature_collection);
vector_layer.destroyFeatures();
vector_layer.addFeatures(feature_collection);
}
});
Im stay using the web console from the WebDeveloper extension for Chrome or
Firefox, and the
last lines says:
-- GET
http://200.85.231.185/sites/all/modules/sar/polygontheme.php?theme=trampas&user=7&plantacioncode=2040504
[HTTP/1.1 200 OK 844ms]
-- no element found @
file:///home/user/Downloads/OpenLayers-2.11/examples/vector_remote_gml.html:1
vector_remote_gml.html .. is the file where im working .
Also i use a code similar to the A option mentioned before .. But this code
only work if the
applications runs in the same machine that the source file, here is:
var Layer_tramp = new OpenLayers.Layer.Vector("Tramp_GML",
{
strategies: [ new OpenLayers.Strategy.Fixed() ],
protocol: new OpenLayers.Protocol.HTTP({
url:
"http:200.85.231.185/sites/all/modules/sar/polygontheme.php?theme=trampas&user=7&plantacioncode=2040504",
format: new OpenLayers.Format.GML.v3(),
}),
projection: new OpenLayers.Projection("EPSG:4326")
}
);
map.addLayer(Layer_tramp);
Thanks a lot for the comments .. !
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/using-Request-GET-vs-Layer-with-strategy-protocol-format-tp4533257p4686966.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list