[OpenLayers-Users] Cluster Layers - Correct placemark format?
Allan Henderson
allanhenderson at gmail.com
Mon Nov 24 11:53:04 EST 2008
Hi Christopher,
Here's the code:
<script type="text/javascript">
window.onload = function(){
var lon = -2.900000;
var lat = 55.160000;
var proj = new OpenLayers.Projection("EPSG:4326");
var center = new OpenLayers.LonLat(lon, lat);
var zoom = 4;
var map, layer;
var src = new OpenLayers.Projection('EPSG:4326');
var dest = new OpenLayers.Projection('EPSG:900913');
var marker_style = ({
'pointRadius' : "${radius}",
'fillColor' : '#9ED652',
'fillOpacity' : 0.8,
'strokeColor' : '#ffffff',
'strokeWidth' : '1',
'strokeOpacity' : 0.8
}, {
context: {
radius: function(feature) {
return Math.min(feature.attributes.count, 7) + 3;
}
}
});
var options = {
'projection': new OpenLayers.Projection("EPSG:900913"),
'displayProjection': new OpenLayers.Projection("EPSG:4326"),
'units': "m",
'maxResolution': 156543.0339,
'maxExtent' : new
OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
'controls':[new OpenLayers.Control.Navigation(), new
OpenLayers.Control.ZoomPanel()],
'numZoomLevels' : 18
};
// base map
map = new OpenLayers.Map('map', options);
// - MS Virtual Earth Layer
var baselayer = new OpenLayers.Layer.VirtualEarth("Virtual Earth",
{ 'type': VEMapStyle.Hybrid, "sphericalMercator": true});
map.addLayer(baselayer);
// Controls for the map
map.addControl(new OpenLayers.Control.LayerSwitcher());
var layermarkers = new OpenLayers.Layer.Vector("Markers",{
strategies: [
new OpenLayers.Strategy.Fixed(),
new OpenLayers.Strategy.Cluster()
],
protocol: new OpenLayers.Protocol.HTTP({
url: "kml/placemarks.kml",
format: new OpenLayers.Format.KML({
internalProjection: new OpenLayers.Projection("ESPG:
900913"),
externalProjection: new OpenLayers.Projection("ESPG:4326")
})
}),
styleMap:new OpenLayers.StyleMap({
"default": marker_style,
"select": {
fillColor: "#8aeeef",
strokeColor: "#32a8a9"
}
})
});
map.addLayer(layermarkers);
center.transform(proj, map.getProjectionObject());
map.zoomToMaxExtent();
// Vector Layers for the Campsites
//
map.setCenter(center, zoom);
}
</script>
Thanks!
Allan
On 24 Nov 2008, at 15:45, Christopher Schmidt wrote:
> On Mon, Nov 24, 2008 at 03:44:40PM +0000, Allan Henderson wrote:
>> Hi there,
>>
>> I'm trying to implement a Cluster layer from a KML feed. The feed on
>> it's own is working fine but all falls apart when I try a cluster
>> strategy. So I'm thinking this method doesn't work
>
> It should. Are you using a strategy.Fixed? Can you share your code?
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
More information about the Users
mailing list