I am using OpenLayers 2.13.1. I could get my clustering work for the vector layer but when I try adding a styleMap to the vector layer, neither the clusters nor the individual points are visible on the map. Below is my code.
function PlotExposuresOnMap(selectedExposures) { if (exposureLayer) map.removeLayer(exposureLayer);
var context = { symbol: function (feature) { if (feature.cluster) { return '../icons/cluster.png'; } else { return '../icons/marker.png'; } } } var template = { externalGraphic: "${symbol}" } var style = new OpenLayers.Style(template, { context: context }); var clusterStrategy = new OpenLayers.Strategy.Cluster({ distance: 20 }); var geojson_format = new OpenLayers.Format.GeoJSON({ 'internalProjection': new OpenLayers.Projection("EPSG:900913"), 'externalProjection': new OpenLayers.Projection("EPSG:4326") }); exposureLayer = new OpenLayers.Layer.Vector("Exposures", { strategies: [clusterStrategy] /*, styleMap: new OpenLayers.StyleMap(style)*/}); map.addLayer(exposureLayer); exposureLayer.addFeatures(geojson_format.read(selectedExposures)); }I wanted to display different icons for the markers based on whether it is a clsuter or an individual marker. I am really not sure what is missing. Any help to get it working is highly appreciated.
أكثر...
function PlotExposuresOnMap(selectedExposures) { if (exposureLayer) map.removeLayer(exposureLayer);
var context = { symbol: function (feature) { if (feature.cluster) { return '../icons/cluster.png'; } else { return '../icons/marker.png'; } } } var template = { externalGraphic: "${symbol}" } var style = new OpenLayers.Style(template, { context: context }); var clusterStrategy = new OpenLayers.Strategy.Cluster({ distance: 20 }); var geojson_format = new OpenLayers.Format.GeoJSON({ 'internalProjection': new OpenLayers.Projection("EPSG:900913"), 'externalProjection': new OpenLayers.Projection("EPSG:4326") }); exposureLayer = new OpenLayers.Layer.Vector("Exposures", { strategies: [clusterStrategy] /*, styleMap: new OpenLayers.StyleMap(style)*/}); map.addLayer(exposureLayer); exposureLayer.addFeatures(geojson_format.read(selectedExposures)); }I wanted to display different icons for the markers based on whether it is a clsuter or an individual marker. I am really not sure what is missing. Any help to get it working is highly appreciated.
أكثر...