[OpenLayers-Users] FW: FramedCloud GEORSS support [completed]

Simone Gadenz simone.gadenz at jrc.it
Wed Apr 2 10:21:31 EDT 2008


My 2 cents:

I load the GeoRSs through a GML layer using a GeoRSS format. I modified a
bit the GeoRSS format class to give the user the possibility of defining the
field he wants to use for symbolizations.

This is the html that works for me:

var in_options = {
             'internalProjection': new OpenLayers.Projection("EPSG:900913"),
             'externalProjection': new OpenLayers.Projection("EPSG:4326"),
             'type':'eventType alertLevel'
        };
        
        // create a GeoRSS layer
        // Inorder to accomodate all the possible geometry type the layer
must be a GML layer with a GeoRSS format
        // defining styles
 	    var styleMap = new OpenLayers.StyleMap({
                fillOpacity: 1,
                pointRadius: 10
            });
        // create a lookup table with different symbolizers for 0, 1 and 2
        var lookup = {
            EQGreen: {externalGraphic: "images/eqgreen.jpg"},
            EQOrange: {externalGraphic: "images/eqorange.jpg"},
            EQRed: {externalGraphic: "images/eqred.jpg"},
            TCGreen: {externalGraphic: "images/tcgreen.jpg"},
            TCOrange: {externalGraphic: "images/tcorange.jpg"},
            TCRed: {externalGraphic: "images/tcred.jpg"},
            FLGreen: {externalGraphic: "images/flgreen.jpg"},
            FLOrange: {externalGraphic: "images/florange.jpg"},
            FLRed: {externalGraphic: "images/flred.jpg"},
            VOGreen: {externalGraphic: "images/vogreen.jpg"},
            VOOrange: {externalGraphic: "images/voorange.jpg"},
            VORed: {externalGraphic: "images/vored.jpg"}
        }
        // add rules from the above lookup table, with the keyes mapped to
        // the "type" property of the features, for the "default" intent
        styleMap.addUniqueValueRules("default", "type", lookup);
 	    var georssformat = new OpenLayers.Format.GeoRSS(in_options);
        var gmllayer = new OpenLayers.Layer.GML("GDACS Alerts", "RSS.xml",
{'format': georssformat, styleMap: styleMap});

Then I added these functions 

function onPopupClose(evt) {
            selectControl.unselect(selectedFeature);
    }
      
    function onFeatureSelect(feature) {
        selectedFeature = feature;
        popup = new OpenLayers.Popup.FramedCloud("chicken", 
 
feature.geometry.getBounds().getCenterLonLat(),
                                 new OpenLayers.Size(250,100),
                                 "<div style='font-size:0.8em'><A
href='"+feature.data.link+"'>" + feature.data.title +"</A><br /><div
id='popupcontent'  style='font-size:1em'>" +
feature.data.description+"</div></div>",
                                 null, true, onPopupClose);
        feature.popup = popup;
        map.addPopup(popup);
    }
    
    function onFeatureUnselect(feature) {
        map.removePopup(feature.popup);
        feature.popup.destroy();
        feature.popup = null;
    }    

Hope this helps!


Simone




More information about the Users mailing list