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

Ken Sanderson ken at rockies.ca
Tue Jun 22 08:50:23 EDT 2010


Thanks Chris, that indeed did fix the problem. I assumed since I had 
loaded all the defs for proj4js locally that it would only use those and 
not need to sr.org for them, is that not the case?

Ken

christopher.schmidt at nokia.com wrote:
> On Jun 22, 2010, at 7:42 AM, ext Ken Sanderson wrote:
> 
>> 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.
> 
>  * OpenLayers only knows how to transform to/from EPSG:900913/EPSG:4326
>    by default.
>  * With proj4js support, it can support more projections, but only based
>    on the available definitions.
>  * If proj4js does not have projection information, it will attempt to 
>    load http://spatialreference.org/ref/epsg/26911/proj4js/ into your
>    page.
>  * This operation is non-blocking -- meaning proj4js has no way to know
>    when it is done and 'pause'.
> 
> As a result, when you first attempt to transform, proj4js will try to 
> load http://spatialreference.org/ref/epsg/26911/proj4js/ , it will take
> a second, and in the meantime, your transform will do nothing.
> 
> The fix to this is to include:
> 
>   Proj4js.defs["EPSG:26911"] = "+proj=utm +zone=11 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";
> 
> directly in the source of your page.
> 
> In general, it's polite to do this anyway so as to not hit sr.org for 
> every page load.
> 
> Best Regards,

-- 
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