Open AndrewGoal opened 13 years ago
The prototype functions are not shown in the output of the node console. Please check: OpenLayers.Geometry.Point.prototype
or use:
var p = new OpenLayers.Geometry.Point(2,3);
console.log(p.equals.toString)
console.log(p.equals(p));
I am sorry , I made a mistake:p It works
But :
new OpenLayers.Geometry.LinearRing(new OpenLayers.Geometry.Point(0,0)) { id: 'OpenLayers.Geometry.LinearRing_150', components: [ { id: 'OpenLayers.Geometry.Point_149', x: 0, y: 0, parent: [Circular] }, { id: 'OpenLayers.Geometry.Point_149', x: 0, y: 0, parent: [Circular] } ], bounds: null }
new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(0,0),new OpenLayers.Geometry.Point(0,5)]) TypeError: Object POINT(0 0),POINT(0 5) has no method 'equals' at Object.addComponent (/home/andrew/node_modules/openlayers/lib/OpenLayers.js:617:406) at Object.addComponents (/home/andrew/node_modules/openlayers/lib/OpenLayers.js:559:51) at Object.
(/home/andrew/node_modules/openlayers/lib/OpenLayers.js:555:344) at Object. (/home/andrew/node_modules/openlayers/lib/OpenLayers.js:581:274) at Object. (/home/andrew/node_modules/openlayers/lib/OpenLayers.js:581:666) at Object. (/home/andrew/node_modules/openlayers/lib/OpenLayers.js:584:213) at Object.initialize (/home/andrew/node_modules/openlayers/lib/OpenLayers.js:617:272) at [object Context]:1:72 at Interface. (repl.js:171:22) at Interface.emit (events.js:64:17)
and
new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(0,0),new OpenLayers.Geometry.Point(0,5)])
works in browser
Strange problem... If I run your example in the node-console I get the same error. If I try your example in a file everything seems to work.
Which version do you use in the browser?
Yes, I try in a file run with node too, It works well. very strange ... maybe there are some bugs in nodejs's repl ?
I run these codes at web page ( http://www.openlayers.org/dev/examples/example.html ) console in chrome, it works.
OpenLayers.VERSION_NUMBER "$Revision: 10995 $"
var OpenLayers = require('openlayers').OpenLayers;
var pl = new OpenLayers.Geometry.Polygon([ new OpenLayers.Geometry.LinearRing([ new OpenLayers.Geometry.Point(0,0), new OpenLayers.Geometry.Point(0,5), new OpenLayers.Geometry.Point(5,5), new OpenLayers.Geometry.Point(5,0) ]) ]);
console.log(pl.components);
$ node /home/andrew/Projects/openlayerDebug.js [ { id: 'OpenLayers.Geometry.LinearRing_6', components: [ [Object], [Object], [Object], [Object], [Object] ], bounds: null, parent: { id: 'OpenLayers.Geometry.Polygon_7', components: [Circular], bounds: null } } ]
OpenLayers.Geometry.Point.prototype's functions lost in Point object