This is our first foray into OpenLayers so it could be that we're not using best practices or something similar, but we're having intermittent performance with a vector layer that we'd like to resolve. The background is explained http://osgeo-org.1803224.n2.nabble.com/vector-layer-with-highest-zIndex-not-overlaying-other-vector-layers-td5592538.html in this thread , but basically we're trying to get around the fact that IE becomes unusable when using a vector layer.
For now we're bailing on the "2nd vector layer for selectable features" until we can resolve this issue: if we can't resolve this, we may have to resort to proprietary APIs (Bing, Esri, etc.) -- perish the thought. (Time probably won't allow this). Our solution for the problem stated was to: - show vector layer only at or above zoom level 10 - use a cluster strategy - show only features within the current map extent (i.e. do a callback every time the map extent changes) This works, though it took some creativity to get selected features on the layer to persist between extent changes since the layer is repopulated every time the extent changes. The problem now is that some clustered features are not displaying in the map extent when they should be. If the user zooms out, they are displayed, and when zoomed back in, they correctly appear where they didn't before. When debugging in FireFox the features are in an array of features added to the vector layer with addFeatures(), but they're not in the layer.features array afterwards and not until the map is zoomed (details in the code section below). If I turn the cluster strategy off, the features appear every time at all scales. But IE is unusable: even with only 14 features it takes several seconds to respond to toggling the vector layer and to extent changes. (This is where I wonder if there's a best practice that we're missing: surely vector layers with more than 14 features are being used with IE?!?!) This is a code sample (note that the map has a value of 'OnMoveEnd' for the 'moveend' eventListener): OnMoveEnd: function() { if (map.getZoom() >= minZoomLevel) { // This next line simply defines a Callback handler for a .NET library that we're using (DevExpress) MapInitLocationsCallback.CallbackComplete.AddHandler(HandleMapInitLocsSuccess); MapInitLocationsCallback.PerformCallback(mapExtent); . . . } HandleMapInitLocsSuccess: function(s, e) { locFeatures = null; // 'eval' the results of the 'get locations' callback to get the JSON representation of the features locs= eval("(" + e.result + ")"); // Build an array of location features with associated attributes. locFeatures = GetLocations(locs); // locFeatures is an array of OpenLayers.Feature.Vector // locsLayerDef is the OpenLayers.Layer.Vector locsLayerDef.addFeatures(locFeatures); . . . }, Here's what seems to be happening (as seen when debugging in FF): 1. Initial extent: map shows 5 features, none of which are clustered (which is correct). If I set a breakpoint at 'locsLayerDef.addFeatures(locFeatures)', I see the five features in locFeatures and none in locsLayerDef.features, which is correct. When I step thru locsLayerDef.addFeatures(locFeatures), I correctly see the 5 features in the locsLayerDef.features array. 2. Zoom out: Now locFeatures correctly has 10 features and locsLayerDef.features still has the original 5. Some of these 10 should cluster according to my strategy. When I step thru locsLayerDef.addFeatures(), it still shows only the original 5 features and the clustered features are not displayed on the map. 3. Zoom out again: The clustered features appear on the map immediately, even before the code reaches HandleMapInitLocsSuccess(). At my breakpoint (before the addFeatures()), locsLayerDef.features now has my clustered features. locFeatures now has 14 features and when I step thru locsLayerDef.addFeatures(), it again appears as though the features in locFeatures are not added to it. 4. Zoom in: The clustered features that did not appear in step #2 appear now at the same scale. When the features appear in the layer.features array seems to lag by one zoom event, though this may just have to do the timing of my breakpoint and when clustering actually happens and/or when the features are actually added to the vector layer (or even whether FF is correctly refreshing the contents of my variables in the watch window) but after stepping through addFeatures() I'd expect to see them in the layer's features array. However they're not there until I zoom again. Also when the features show up in the layer.features array seems consistent with when I see them on the map (so I don't think it's the FF watch window). Am I missing a crucial step? Or is there timing issue w/r/t when I should be adding the features to the vector layer? Something else? -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/cluster-strategy-not-displaying-all-features-until-zoom-out-in-tp5596336p5596336.html Sent from the OpenLayers Dev mailing list archive at Nabble.com. _______________________________________________ Dev mailing list d...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-dev