If you want your circle and your point to be combined together into one object, use OpenLayers.Geometry.Collection . Using this method, you can apply some controls, such as DragFeature, that will work with elements in the collection immediately.
var defaultStyle = new OpenLayers.Style({ externalGraphic:'${icon}', graphicHeight: 25, graphicWidth: 21, graphicXOffset:-12, graphicYOffset:-25 }); var styleMap = new OpenLayers.StyleMap({'default': defaultStyle }); var vectorLayer = new OpenLayers.Layer.Vector("Overlay",{styleMap: styleMap }); var aPoint = new OpenLayers.Geometry.Point( lonLat.lon, lonLat.lat ); var aCircle = OpenLayers.Geometry.Polygon.createRegularPolygon( aPoint, 50000, 40, 0 ); var aCirclePoint = new OpenLayers.Geometry.Collection( [ aCircle, aPoint ] ); var aCirclePoint_feature = new OpenLayers.Feature.Vector( aCirclePoint ); aCirclePoint_feature.attributes = { icon:'/img/marker.png' } vectorLayer.addFeatures( [ aCirclePoint_feature ] );
source share