javascript - "Object has no method 'getBounds'" error in OpenLayers -
i'm using code draw point on 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 error console:
uncaught typeerror: object point(33, 33) has no method 'getbounds'
what doing wrong?
for sake of completeness, received similar error while adding polygon (not point) raw wkt data. error there no bounds occur because object of wrong type.
when call addfeatures
, expects array of openlayers.feature.vector
objects, created format.read
.
var wkt_parser = new openlayers.format.wkt(); var wkt_data_parsed = wkt_parser.read(some_raw_wkt_data_string); layer.addfeatures([wkt_data_parsed]);
Comments
Post a Comment