[OpenLayers-Users] projection transform, not working on first load?

Ken Sanderson ken at rockies.ca
Tue Jun 22 07:42:23 EDT 2010


So I am using a few transforms with my openlayers mapping application. 
Generally speaking it works fine, however it seems to never transform 
properly when the application first loads.

So for example I have a database with EPSG:26911 points in it. I create 
a point with those coordinates, then transform them to 900913 before 
adding them as a feature to a vector layer.

Points will not show up, but if I put alert(point.x); then I will see 
that the very first point will give me the UTM coordinate, but then 
after that they will all be transformed appropriately and they will 
display on the map and the alert gives me the web Mercator coordinate. 
Without the alert though it doesnt 'trigger' it to work properly and 
none of the points will be displayed.

Here is what I mean for my point feature.

var point = new 
OpenLayers.Geometry.Point('.$row['place_e'].','.$row['place_n'].');

point.transform(new OpenLayers.Projection("EPSG:26911"), new 
OpenLayers.Projection("EPSG:900913"));

//alert(point.x);

var pointFeature = new OpenLayers.Feature.Vector(point);
pointFeature.attributes = {icon: "./logo_icon_square.png", placeid: 
"'.$row['place_id'].'"};

datapoints.addFeatures([pointFeature]);


I have found this same problem when tranforming the bounds object of my 
map. If I have a click function that gives me the map coordinates, the 
very first click is always the pre-tranform coordinate, after that it 
functions fine.

Is there a trick to this that I am missing?

Thanks.

Ken


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the Users mailing list