Hi,

thanks. It is so simple and works.

I have worked with documentation for OpenLayers-2.10 and there was no function refresh() for vector layers available.
http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Layer/Vector-js.html
Also not here:
http://dev.openlayers.org/apidocs/files/OpenLayers/Layer/Vector-js.html
But I found the refresh function now in the developer/internal library documentation:
http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html

That means the function refresh() could changed or removed from API in future?

Regards,
Hareck.

-----Ursprüngliche Nachricht----- From: Andreas Hocevar
Sent: Friday, January 14, 2011 2:56 PM
To: har.eck
Cc: [email protected]
Subject: Re: [OpenLayers-Users] Changing URL in vector layer

Hi,

all you have to do is:

myVectorLayer.refresh({url: newUrl});

This is how it works:
1) Layer.Vector::refresh triggers the refresh event
2) Strategy.Fixed listens to the refresh event, and calls Strategy.Fixed::load 3) Strategy.Fixed::load calls Protocol.HTTP::read with the options passed to Layer.Vector::refresh, and url is a recognized option for Protocol.HTTP::read

Regards,
Andreas.

On Jan 14, 2011, at 08:52 , har.eck wrote:


Hi all,

I add a vector layer with GPX file to my map. Now I will change the url of GPX file in vector layer. There is no special function for this. For GML layer it is possible to call setUrl(). This isn’t possible for vector layers, so I do this:


function setNewUrl(){
  myVectorLayer.setVisibility(false);
  myVectorLayer.destroyFeatures();
  myVectorLayer.protocol.url = newUrl;
  myVectorLayer.protocol.options.url = newUrl;
  myVectorLayer.drawn = false;
  myVectorLayer.setVisibility(true);
}

My vector layer:

var myVectorLayer, map;
myVectorLayer = new OpenLayers.Layer.Vector(
    myLayerName,
    {
      protocol: new OpenLayers.Protocol.HTTP({
          url: myUrl,
          format: new OpenLayers.Format.GPX()
      }),
      strategies: [new OpenLayers.Strategy.Fixed()],
      displayInLayerSwitcher: false,
      style: {strokeColor: "blue", strokeWidth: 4, strokeOpacity: 0.5},
      projection: new OpenLayers.Projection("EPSG:4326")
    }
  );
  myVectorLayer.setVisibility(true);
  map.addLayer(myVectorLayer);
}

My function setNewUrl() doesn’t work.
I can’t find the correct solution in openLayers sources.
Which function reads the file after changing url? What is here wrong?

Thanks Hareck
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to