x

Cluster und einzelne Feature mit unterschiedlicher Anzeige


  1. Cluster und einzelne Feature mit unterschiedlicher Anzeige · shadowdiver (Gast) · 25.06.2012 15:17 · [flux]

    Hallo,

    ich habe nach dem Vorbild von http://jorix.github.com/OL-FeaturePopup … er-FP.html eine Karte mir geclusterten Features erstellt.

    OpenLayers.Format.Flickr␣=␣OpenLayers.Class(OpenLayers.Format,␣{
    read:␣function(obj)␣{
    var␣photos␣=␣new␣Array();
    var␣photo,␣point,
    feature;
    photos.push({longitude:␣8.807357,␣latitude:␣53.075813,␣title:␣"Test1",␣bild:␣"example.png"});
    photos.push({longitude:␣8.808367,␣latitude:␣53.075813,␣title:␣"Test2",␣bild:␣"example.png"});
    photos.push({longitude:␣8.807357,␣latitude:␣53.076823,␣title:␣"Test3",␣bild:␣"example.png"});
    photos.push({longitude:␣8.809357,␣latitude:␣53.076823,␣title:␣"Test4",␣bild:␣"example.png"});
    for(var␣i=0,l=photos.length;␣i<l;␣i++)␣{
    photo␣=␣photos[i];
    point␣=␣new␣OpenLayers.Geometry.Point(photo.longitude,␣photo.latitude);
    feature␣=␣new␣OpenLayers.Feature.Vector(point,␣{
    id:␣i,
    lon:␣photo.longitude,
    lat:␣photo.latitude,
    title:␣photo.title,
    bild:␣photo.bild,
    description:␣photo.description
    },␣stylesSwingerImage);
    features.push(feature);
    }
    return␣features;
    }
    });
    
    var␣style␣=␣new␣OpenLayers.Style({
    pointRadius:␣"${radius}",
    fillColor:␣"#ffcc66",
    fillOpacity:␣0.8,
    strokeColor:␣"#cc6633",
    strokeWidth:␣2,
    strokeOpacity:␣0.8
    },␣{
    context:␣{
    radius:␣function(feature)␣{
    return␣Math.min(feature.attributes.count,␣7)␣+␣3;
    }
    }
    });
    
    var␣photos␣=␣new␣OpenLayers.Layer.Vector("Photos",␣{
    projection:␣"EPSG:4326",
    strategies:␣[
    new␣OpenLayers.Strategy.Fixed(),
    new␣OpenLayers.Strategy.Cluster()
    ],
    protocol:␣new␣OpenLayers.Protocol.Script({
    url:␣"http://api.flickr.com/services/rest",
    params:␣{
    api_key:␣'',
    format:␣'json',
    method:␣'',
    extras:␣'',
    per_page:␣150,
    page:␣1,
    bbox:␣[-180,␣-90,␣180,␣90]
    },
    callbackKey:␣'jsoncallback',
    format:␣new␣OpenLayers.Format.Flickr()
    }),
    styleMap:␣new␣OpenLayers.StyleMap({
    "default":␣style,
    "select":␣{
    fillColor:␣"#8aeeef",
    strokeColor:␣"#32a8a9"
    }
    })
    });
    

    Nun möchte ich, dass Cluster die nur ein Feature enthalten anders aussehen als die mit mehr Features. Am Besten sollte dann ein Marker angezeigt werden.

    Hat jemand eine Idee wie sich sowas umsetzen läst? Habe dazu leider keine Lösung im Netz gefunden.

    Noch was Anderes, wie bekomme ich da die Flickr-Api raus, habe meine eigenen Daten zum Anzeigen. Wenn ich die Api raus nehme und versuche auf anderem Weg die Features einzutragen werden keine Daten mehr angezeigt.