[OpenLayers-Users] Question re. displaying large dataset
r_mac
mchugh.r at gmail.com
Sun Feb 20 10:59:56 EST 2011
Hi, I hope it's ok to post a newbie question here, I have searched around for
a few days and have been so far unable to resolve my problem.
I have a large dataset (2850 points) which I would like to display using
OpenLayers. At present, I am using a simple text layer to display the
locations, however it results in extremely slow browser performance.
I have looked at several different solutions to this problem, including
Dynamic POIs and clustering. It seems to me that clustering is probably the
best solution to my problem, but I am having trouble getting it to work. At
present, the location data is in a tabbed text file. In order to implement a
clustering strategy, it seems like I need to change the layer from a text
layer into a Vector layer and then create a clustering strategy.
I have created the following code, but when I load the file (via a
localhost), the POI layer does not display at all.
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
function init(){
map = new OpenLayers.Map("map");
map.addLayer(new OpenLayers.Layer.OSM());
var strategy = new OpenLayers.Strategy.Cluster({distance:15, threshold:3});
var curLayer = new OpenLayers.Layer.Vector("layer", {
strategies: [strategy],
protocol: new OpenLayers.Protocol.HTTP({
url: "location-data.txt",
format: new OpenLayers.Format.Text()
})
});
map.addLayer(curLayer);
//Set start centrepoint and zoom
var lonLat = new OpenLayers.LonLat( -6.25, 53.33 )
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS
1984
map.getProjectionObject() // to Spherical Mercator Projection
);
var zoom=9;
map.setCenter (lonLat, zoom);
}
At present, I'm not sure what the problem is. It could be a problem with the
text file (does it need to be in another format to work as a vector layer?)
or it could be something else.. Any help on this would be much appreciated.
Thanks,
Ronan
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Question-re-displaying-large-dataset-tp6045994p6045994.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list