Add setUrl function for GML layer. Thanks to a well done patch (with tests!)
from Ian Johnson. (Closes #1264) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5776 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -10,6 +10,7 @@ John Frank
|
|||||||
Sean Gilles
|
Sean Gilles
|
||||||
Pierre Giraud
|
Pierre Giraud
|
||||||
Andreas Hocevar
|
Andreas Hocevar
|
||||||
|
Ian Johnson
|
||||||
Eric Lemoine
|
Eric Lemoine
|
||||||
Philip Lindsay
|
Philip Lindsay
|
||||||
Corey Puffault
|
Corey Puffault
|
||||||
|
|||||||
@@ -97,7 +97,21 @@ OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
|
|||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: setUrl
|
||||||
|
* Change the URL and reload the GML
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* url - {String} URL of a GML file.
|
||||||
|
*/
|
||||||
|
setUrl:function(url) {
|
||||||
|
this.url = url;
|
||||||
|
this.destroyFeatures();
|
||||||
|
this.loaded = false;
|
||||||
|
this.events.triggerEvent("loadstart");
|
||||||
|
this.loadGML();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: requestSuccess
|
* Method: requestSuccess
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
var name = "GML Layer";
|
var name = "GML Layer";
|
||||||
|
|
||||||
var gml = "./owls.xml";
|
var gml = "./owls.xml";
|
||||||
|
var gml2 = "./mice.xml";
|
||||||
|
|
||||||
// if this test is running online, different rules apply
|
// if this test is running online, different rules apply
|
||||||
var isMSIE = (navigator.userAgent.indexOf("MSIE") > -1);
|
var isMSIE = (navigator.userAgent.indexOf("MSIE") > -1);
|
||||||
@@ -40,6 +41,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
function test_GML_setUrl(t) {
|
||||||
|
t.plan(2);
|
||||||
|
var layer = new OpenLayers.Layer.GML(name, gml);
|
||||||
|
var map = new OpenLayers.Map("map");
|
||||||
|
map.addLayer(layer);
|
||||||
|
t.eq(layer.url, gml, "layer has correct original url");
|
||||||
|
layer.setUrl(gml2);
|
||||||
|
t.eq(layer.url, gml2, "layer has correctly changed url");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user