My application's objective is to
is the clustered feature "hidden" while its cluster is displayed? if so, how can i access it?
i am using openlayers with javascript, loosely based on the sundials example, yet with a cluster strategy.
1 is a standard cluster strategy.
var pointStyleTaxi = new OpenLayers.Style({ externalGraphic: "img/taxi.png", pointRadius: 20, graphicYOffset: -30, fillOpacity: 0.6, 'label': "${label}" }, { context: { label: function(feature) { // clustered features count or blank if feature is not a cluster return feature.cluster ? feature.cluster.length : ""; }, radius: function(feature) { return Math.min(feature.attributes.count*5, 20) + 5; } }});var styleMapClusterTaxi = new OpenLayers.StyleMap({ 'default': pointStyleTaxi,});var clusterStrategyTaxi = new OpenLayers.Strategy.Cluster({ distance: 35, threshold: 2 });var refresh = new OpenLayers.Strategy.Refresh({force: true, active: true});var stops = new OpenLayers.Layer.Vector("Paradas", { styleMap: styleMapClusterTaxi, strategies: [new OpenLayers.Strategy.Fixed(), clusterStrategyTaxi, refresh], projection: map.displayProjection, protocol: new OpenLayers.Protocol.HTTP({ url: "", format: new OpenLayers.Format.KML({ extractStyles: true, extractAttributes: true, maxDepth: 2 }) })});map.addLayers([wms, stops]);i achieve 2 by identifying that the selected feature is a cluster inside onFeatureSelect(event)
if (feature.cluster) {
and proceeding to extract the name of each clustered placemark.
for (var i = 0; i < feature.attributes.count; i++) { var feat = feature.cluster; var featId = feature.cluster.id; var featName = feat.attributes.name;3 is obtained by creating a javascript hyperlink for each clustered placemark
content += "
"+featName+"";}
after clicking on link, 4 is obtained by calling
function popupClear() { //alert('number of popups '+map.popups.length); while( map.popups.length ) { map.removePopup(map.popups[0]); }}which produces Jecabitiba
which is a javascript call to onFeatureSelectFeature('OpenLayers_Feature_Vector_58');
function onFeatureSelectFeature(featId) { var layerNow = map.getLayersByName('Paradas')[0]; var layerFeatCount = layerNow.features.length; //alert ("featId: "+featId+"\r\nlayer name:"+layerNow.name+"\r\nlayerFeatCount:"+layerFeatCount); for(var i=0; i
- click on a cluster and produce a popup
- with a list of all placemarks clustered there
- where every entry is a hyperlink
- that closes current popup
- and opens a new popup with data from placemark
is the clustered feature "hidden" while its cluster is displayed? if so, how can i access it?
i am using openlayers with javascript, loosely based on the sundials example, yet with a cluster strategy.
1 is a standard cluster strategy.
var pointStyleTaxi = new OpenLayers.Style({ externalGraphic: "img/taxi.png", pointRadius: 20, graphicYOffset: -30, fillOpacity: 0.6, 'label': "${label}" }, { context: { label: function(feature) { // clustered features count or blank if feature is not a cluster return feature.cluster ? feature.cluster.length : ""; }, radius: function(feature) { return Math.min(feature.attributes.count*5, 20) + 5; } }});var styleMapClusterTaxi = new OpenLayers.StyleMap({ 'default': pointStyleTaxi,});var clusterStrategyTaxi = new OpenLayers.Strategy.Cluster({ distance: 35, threshold: 2 });var refresh = new OpenLayers.Strategy.Refresh({force: true, active: true});var stops = new OpenLayers.Layer.Vector("Paradas", { styleMap: styleMapClusterTaxi, strategies: [new OpenLayers.Strategy.Fixed(), clusterStrategyTaxi, refresh], projection: map.displayProjection, protocol: new OpenLayers.Protocol.HTTP({ url: "", format: new OpenLayers.Format.KML({ extractStyles: true, extractAttributes: true, maxDepth: 2 }) })});map.addLayers([wms, stops]);i achieve 2 by identifying that the selected feature is a cluster inside onFeatureSelect(event)
if (feature.cluster) {
and proceeding to extract the name of each clustered placemark.
for (var i = 0; i < feature.attributes.count; i++) { var feat = feature.cluster; var featId = feature.cluster.id; var featName = feat.attributes.name;3 is obtained by creating a javascript hyperlink for each clustered placemark
content += "
"+featName+"";}
after clicking on link, 4 is obtained by calling
function popupClear() { //alert('number of popups '+map.popups.length); while( map.popups.length ) { map.removePopup(map.popups[0]); }}which produces Jecabitiba
which is a javascript call to onFeatureSelectFeature('OpenLayers_Feature_Vector_58');
function onFeatureSelectFeature(featId) { var layerNow = map.getLayersByName('Paradas')[0]; var layerFeatCount = layerNow.features.length; //alert ("featId: "+featId+"\r\nlayer name:"+layerNow.name+"\r\nlayerFeatCount:"+layerFeatCount); for(var i=0; i