[OpenLayers-Users] proj4js transform
unai
unai_mayo at yahoo.es
Mon Nov 5 08:17:24 PST 2012
Why not?
http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/BaseTypes/LonLat-js.html#OpenLayers.LonLat.transform
Franz, your code works for me:
var proj_4326 = new OpenLayers.Projection('EPSG:4326');
var proj_900913 = new OpenLayers.Projection('EPSG:900913');
var lonlat = new OpenLayers.LonLat(15.638, 48.203);
lonlat.transform(proj_4326, proj_900913);
console.log(lonlat);
console.log(lonlat.lon, lonlat.lat);
lonlat = new OpenLayers.LonLat(15.638, 48.203);
lonlat.transform(
new OpenLayers.Projection("EPSG:4326"),
new OpenLayers.Projection("EPSG:900913")
);
console.log(lonlat);
Outputs:
lon=1740814.196782889,lat=6140693.491671423 { lon=1740814.196782889,
lat=6140693.491671423, CLASS_NAME="OpenLayers.LonLat"}
> The transform method doesn't accept OpenLayers.LonLat as input, use a
> OpenLayers.Geometry.Point or an object that has 'x' and 'y' properties
> as the point to be transformed.
>
> Mike
>
>
> On 05/11/2012 9:16 AM, Franz S. wrote:
>> I have a problem with the "transform"-function when the "proj4js.js" is
>> included.
>>
>> the following code doesnt work:
>>
>> /lonlat = new OpenLayers.LonLat(15.638, 48.203);
>>
>> lonlat.transform(
>> new OpenLayers.Projection("EPSG:4326"), // transform
>> from WGS
>> 1984
>> new OpenLayers.Projection("EPSG:900913") // to Spherical
>> Mercator
>> );/
>>
>> lonlat.lat and lonlat.lon aren't transformed to Spherical Mercator.
>>
>> Can somebody help?
>>
>>
>>
>> --
>> View this message in context:
>> http://osgeo-org.1560.n6.nabble.com/proj4js-transform-tp5014016.html
>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
More information about the Users
mailing list