I’m using this code to draw a point on a map:
function addPointToMap(pMap){
var coordinates = new Array();
// Style Point
var style_blue = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
style_blue.strokeColor = "blue";
style_blue.fillColor = "blue";
// Make Point
coordinates.push(new OpenLayers.Geometry.Point(33, 33));
var pointFeature = new OpenLayers.Feature.Vector(coordinates, null, style_blue);
// Layer
var pointsLayer = new OpenLayers.Layer.Vector("Points Layer");
pointsLayer.addFeatures([pointFeature]);
pMap.addLayer(pointsLayer);
}
I’m getting this error from the console:
Uncaught TypeError: Object POINT(33, 33) has no method 'getBounds'
What am I doing wrong?
For the sake of completeness, I received a similar error while adding a polygon (not a point) from raw WKT data. The error that there are no bounds occur because the object was of the wrong type.
When you call
addFeatures, it expects an array ofOpenLayers.Feature.Vectorobjects, which are created byFormat.read.