[OpenLayers-Users] Add custom attribute for vector feature

Boris T. boris.tkc at googlemail.com
Wed Feb 17 06:37:36 EST 2010


Hi List,

I worte a function which is loading a JSON string via AJAX and creating
markers from the received values (x, y, icon, angle, etc.). This is working
quite well.

What I'm struggling with is that each marker should have a popup with a
description (name, id and other values from the JSON data).

I created a onFeatureSelect function to create the popup

function onFeatureSelect(feature) {
            	selectedFeature = feature;
		var content = feature.attributes.description + feature.attribute.name +
... ;
        	    popup = new OpenLayers.Popup.FramedCloud(null, 
							feature.geometry.getBounds().getCenterLonLat(),
							new OpenLayers.Size(150,300),
							content,
							null, true, function() {onPopupClose(feature)});
				feature.popup = popup;
				feature.attributes.static=true;
      		    feature.attributes.poppedup=true;
            	map.addPopup(popup);
}

What attributes are available for a geometry point? x, y, angel?
Can I create a custom feature.attribute?
Or is there a more accurate way to do that?


Thanks for you help!
Boris
-- 
View this message in context: http://n2.nabble.com/Add-custom-attribute-for-vector-feature-tp4585538p4585538.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list