Hi, You should already know the current projection of the vertices, and you maybe have to reproject them to the map's projection using OpenLayers.Projection.transform() if they are not in the same projection
Best regards, Xurxo Méndez Pérez http://www.sonxurxo.com 2011/1/25 <[email protected]> > Hello, > > Ok, the code works now. But unfortunately it is not quite exactly what I > wanted to have. > Because now the Geometry.Point refers to another place in the map than the > original LonLat-Object, since > it doesn't get projected but just "copied". > > Yes and this the right vocabulary I was searching for: "to project" [image: > Smiley Emoticon] > *How can I project a LonLat-Object to a Geometry-Point, so that both refer > to the same place in the map?* > * > * > *From:* Xurxo Mendez <[email protected]> > *Sent:* Tuesday, January 25, 2011 11:19 AM > *To:* [email protected] > *Subject:* Re: [OpenLayers-Users] How to deal with Geometry.Point and > lonlat > > Hi, > > Sorry, my bad. (I didn't actually test the code). > OpenLayers.LonLat objects hold two properties, 'lon' and 'lat', so you > should try > > var lonlatObject1 = new OpenLayers.LonLat(0.5751265, -0.03368972); > var point1 = new OpenLayers.Geometry.Point(lonlatObject1.lon, > lonlatObject1.lat); > > And also my bad, I click "reply" instead of "reply to all" and the messages > weren't send to the list, so if this works for you please reply yourself to > the list with the solution, so if anyone searches the list and finds your > question can also find the solution. > > Best regards, > > Xurxo Méndez Pérez > > http://www.sonxurxo.com > > > 2011/1/25 <[email protected]> > >> Hello, >> >> Thanks for the help! I tried following code: >> >> var lonlatObject1 = new OpenLayers.LonLat(0.5751265, -0.03368972); >> var point1 = new OpenLayers.Geometry.Point(lonlatObject1.x, >> lonlatObject1.y); >> >> alert(point1.x); >> >> >> alert gives me the message "NaN". I guess that means that result is not a >> number. >> Any ideas why this occurs? Actually the x should be a normal float, >> shouldn't it? >> >> >> >> *From:* Xurxo Mendez <[email protected]> >> *Sent:* Tuesday, January 25, 2011 8:51 AM >> *To:* rikner <[email protected]> >> *Subject:* Re: [OpenLayers-Users] How to deal with Geometry.Point and >> lonlat >> >> Hi, >> >> OpenLayers.LonLat and OpenLayers.Geometry.Point are not directly related >> to each other (someone please correct me if I'm wrong). LonLat objects >> represent simply a longitude and latitude pair, while Point instances >> represent geometries (they are a subclass of OpenLayers.Geometry, and as >> such they can be used wherever a Geometry is expected, as in >> OpenLayers.Feature.Vector instances). >> If you want to create a Point from a LonLat object (I'm not sure if what >> your webapp gives you are OpenLayers.LonLat objects or "latitude and >> longitude info"), you could do something like >> >> var lonlatObject = //obtained from the list-entry >> >> var point = new OpenLayers.Geometry.Point(lonlatObject.x, lonlatObject.y); >> >> and then set the point as the geometry of an OpenLayers.Feature.Vector >> instance, or add it to an array to pass it to the LinearRing constructor. >> >> I hope this helps you! >> >> >> Best regards, >> >> Xurxo Méndez Pérez >> >> http://www.sonxurxo.com >> >> >> 2011/1/24 rikner <[email protected]> >> >>> >>> Hello everyone, >>> >>> this my very first post and I'm new to the whole OpenLayers thing. >>> Let me get to the point quickly... >>> >>> I want to highlight buildings in an OpenLayers Map. >>> I already figured out a way how to do this by using a vectorLayer. >>> I create a linearRing which gets an array of Geometry.Points >>> (representing >>> the coordinates of the building). Then I create a Feature.Vector (here >>> "polygonFeature") with this linearRing and do: >>> vectorLayer.addFeatures([polygonFeature]); >>> >>> So far so good. But I asked myself why I have to use Geometry.Point and >>> not >>> just simply LonLat coordinates? >>> My web-application on which I'm working is showing me a list of >>> buildings. >>> When I click on an list-entry I get a LonLat-Array containing the >>> 'vertices' >>> of the building. So now when I want to highlight my building by doing the >>> above mentioned I need to convert these LonLats into Geometry.Points. How >>> am >>> I supposed to do that? >>> Maybe you could give me short overview how LonLat and Geometry.Points are >>> related to each other. >>> I just can't make a sense of it right now. Thanks already for your help. >>> I >>> would appreciate a quick answer. >>> >>> Best regards - Erik >>> >>> >>> >>> -- >>> View this message in context: >>> http://osgeo-org.1803224.n2.nabble.com/How-to-deal-with-Geometry-Point-and-lonlat-tp5956361p5956361.html >>> Sent from the OpenLayers Users mailing list archive at Nabble.com. >>> _______________________________________________ >>> Users mailing list >>> [email protected] >>> http://lists.osgeo.org/mailman/listinfo/openlayers-users >>> >> >> > > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users > >
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
