[OpenLayers-Users] Cluster Strategy WKT Vectors - not clustering
RFeagin
ryan.feagin at PEACHTREEGEOGRAPHICS.COM
Tue Mar 3 11:21:16 EST 2009
I am having problems with getting a clustering strategy to work on my vector
layer. Here is my layer definition...
vResultsLayer = new OpenLayers.Layer.Vector("Results"),
{ strategies: [new OpenLayers.Strategy.Fixed(),
new OpenLayers.Strategy.Cluster()],
'sphericalMercator': true,
styleMap: new OpenLayers.StyleMap({
"default": style,
"select": {
fillColor: "#8aeeef",
strokeColor: "#32a8a9"
}
})
};
and here is my code that creates the features...
getWKT_Results: function() {
respWKT = OpenLayers.Request.GET({
url: "Map_GetQueryResult.ashx?" + guid(),
success: function(request) {
wkt = new OpenLayers.Format.WKT({
'internalProjection': new
OpenLayers.Projection("EPSG:900913"),
'externalProjection': new
OpenLayers.Projection("EPSG:4326")
});
format = new OpenLayers.Format.XML();
var xmlParser = format.read(respWKT.responseText);
var featureNodes = format.getElementsByTagNameNS(xmlParser,
'*', 'QueryResults');
var ftrArray = new Array();
for (var i = 0; i < format.getElementsByTagNameNS(xmlParser,
'*', 'QueryResults').length; i++) {
try {
ftrArray.push(wkt.read(format.getElementsByTagNameNS(featureNodes[i], '*',
'WKT')[0].text)[0]);
ftrArray[ftrArray.length - 1].fid =
format.getElementsByTagNameNS(featureNodes[i], '*', 'featureID')[0].text;
}
catch (e) {
test = e.toString();
}
}
vResultsLayer .addFeatures(ftrArray);
//try to force clustering because it isn't getting set for
the layer for some reason
//adding these lines did force clustering on, but caused
"this.layer.events" error trying to unregister "beforefeaturesadded" event
//vResultsLayer .strategies = [new
OpenLayers.Strategy.Cluster()];
//vResultsLayer .strategies[0].active = true;
//vResultsLayer .strategies[0].clustering = true;
}
The Features are getting created and added to the layer properly, they just
aren't getting clustered. As you can tell from comments in the code, when
debugging I noticed that the layer wasn't showing any strategies. So I tried
forcing the cluster strategy and activating it. That just caused an error
trying to unregister the "beforefeaturesadded" event. From looking at the
examples and other posts here, I shouldn't have to force it like that
though.
The reason I'm using WTK and parsing the xml is to keep the amount of data
being transferred to a minimum and keep the ability to associate an ID with
each vector so that I can get details for each vector from the database on
select. Feel free to point me in a different direction if I'm going about
this the wrong way.
Thanks for your help
--
View this message in context: http://n2.nabble.com/Cluster-Strategy-WKT-Vectors---not-clustering-tp2416203p2416203.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list