Okay, I think I have figured out how to organize feature, geometry, marker, and popup.
1. Create a feature using OpenLayers.Feature.Vector, name it featureObj 2. Create a marker using OpenLayers.Marker, name it markerObj 3. Assign the marker object to the marker field of the created featured object; ie, featureObj.marker = markerObj. 4. Create a popup using OpenLayers.Popup() constructor. Don't call feature.CreatePopup(), which does not create popup. 5. Assign the popup object to feature.popup. ie, featureObj.popup = new OpenLayers.Popup(...) 6. Add your marker to markers layer. 7. Register a marker clicked event, passing in feature object. 8. Now, inside the marker client event, through your feature object you has access to the marker object, the geometry, and the popup. Done this way, the feature, geometry, marker, and popup, all can be accessed via the feature object. It's one data structure and integral location to access. [Description: cid:[email protected]] Thanks. JK From: [email protected] [mailto:[email protected]] On Behalf Of JK Chen Sent: Tuesday, June 07, 2011 4:32 PM To: [email protected] Subject: [OpenLayers-Users] marker can be created from feature? The document says such a function exists but the documentation says it returns null. Is this a complete work? 1. What is the right way to create markers? Via feature? Or via marker layers. If through marker layer, then I have two piece of data structures to maintain, which is not good practice. 2. OpenLayers.Feature.Vector does not have property for marker, but OpenLayers.Feature does have such a property. From the naming of these two class, it appears to me that one is the parent. Parent has a property, but the child has no such property. That sounds weird to me... Your insights are appreciated. JK OpenLayers.Feature.Vector ----------------------------------------------------------- createMarker createMarker: function() HACK we need to decide if all vector features should be able to create markers Returns {OpenLayers.Marker<http://dev.openlayers.org/docs/files/OpenLayers/Marker-js.html#OpenLayers.Marker>} For now just returns null
<<inline: image001.jpg>>
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
