[OpenLayers-Users] transformation issues

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Wed Jun 22 13:24:39 EDT 2011


Hi all,

I'm using a map with no options and an OSM base layer. Am I right is
assuming that the map inherits OSM's projection of 900913? I'm confused
because I transform my arbitrarily set center via

map.setCenter(new OpenLayers.LonLat(-90, 38).transform(new
OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()),12);


but I transform my re-set center (after geolocating) via

var temp = map.getCenter().transform(new
OpenLayers.Projection("EPSG:900913"),new
OpenLayers.Projection("EPSG:4326"));


in order to be able to feet the twitter search api a set of coordinates that
it understands. And further confusing me is the necessity to reproject the
coords that I'm pulling into from the geolocation API, as theoretically
they're already in EPSG 4326 (WGS 1984)

var feat = new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point(position.coords.longitude,position.coords.latitude).transform(new
OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()),14);


yet without the transform the points get dumped at 0,0.

Finally, I'm pulling in coordinates from the twitter search api, and I can
verify that they're in lat-lon, and getting passed to my point. The issue is
that they're getting places at 0,0. Clearly this is because they're not
being properly transformed before getting added to the layer,  BUT when I
apply any of the previous methods to transform the point, my lat value gets
corrupted into a NAN.

if (tweet.geo){
var lon = tweet.geo.coordinates[0];
var lat = tweet.geo.coordinates[1];
tweet.point = new OpenLayers.Geometry.Point(lon,lat);
}
// in another function
var twtfeat = new OpenLayers.Feature.Vector(tweet.point);
tweetz.addFeatures(twtfeat);

how do I work around this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110622/aa6b6cc5/attachment.html


More information about the Users mailing list