markers in vector layer not displaying

classic Classic list List threaded Threaded
2 messages Options
crb
Reply | Threaded
Open this post in threaded view
|

markers in vector layer not displaying

crb
I'm having a problem displaying markers in a vector layer.  If I change my styleMap to be default OL graphics (and not markers) then it works fine.  When my styleMap is the marker styleMap, if I view the properties for my map.layers.layer.styleMap.styles.default.rules.0.symbolizer, the value of 'externalGraphic' is correct.  And in fact, as a troubleshooting option I used the fully-qualified URL to the graphic file and that same URL displays fine in a browser.  The features in my layer are all using a renderIntent of 'default'.   I've also set the graphicZIndex on my styleMap to 100, but still no markers (in IE, FF and Chrome).

Here is the code in the order executed:


var olmap;

var markerLayerStyleMap = new OpenLayers.StyleMap({
    'fillOpacity': 1,
    'pointRadius': 10,
    'graphicZIndex': 100
});

var markerLayer = new OpenLayers.Layer.Vector('Points', {
    styleMap: markerLayerStyleMap,
    displayInLayerSwitcher: false,
    alwaysInRange: true,
    isBaseLayer: false
});

var options =   
{                                                       
    projection: mapprj,    // EPSG:102113
    displayProjection: dspprj,   // EPSG:4326
    units: "m",
    maxResolution: 156543.0339,
    maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34)
};
		
olmap = new OpenLayers.Map('map', options);

// road and aerial are bing base layers
olmap.addLayers([road, aerial, markerLayer]);

var iconMap = new Array();

// resolve an array of these:
iconMap['FIRST'] = 'http://localhost:7777/app/Icons/012.png';
iconMap['SECOND'] = 'http://localhost:7777/app/Icons/031.png';
. . .

var lookup = new Object();

for (key in iconMap)
{
    if ( !lookup[key] ) {
        lookup[key] = { 'externalGraphic' : iconMap[key] }
    }
}

markerLayerStyleMap.addUniqueValueRules("default", "ei", lookup);

. . .

// for each config in featureConfigs:
{
    var lonLat = new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.projection);
    var feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat));

    olFeatureArray[index] = feature;
    . . .
}

//olmap.removeLayer(markerLayer);   // tried this, made no difference
markerLayer.addFeatures(olFeatureArray);
//olmap.addLayer(markerLayer);       // tried this, made no difference
crb
Reply | Threaded
Open this post in threaded view
|

Re: markers in vector layer not displaying

crb
Figured this out.  It was the way I was creating my vector features (which I just noticed was the only part of my code that I didn't include in my original post).  Basically the feature properties were applied directly to the feature object instead of to the feature.attributes object, and the styleMap rules look at feature.attributes.property.