OpenLayers: transform GPS coordinates to EPSG:25832 -
i want gps coordinates button click , change them epsg:25832 format center map. here have coded far:
jquery('#btngps').click(function() { if (navigator.geolocation) { navigator.geolocation.getcurrentposition(success); } else { alert("not supported!"); } }); function success(position) { alert(position.coords.longitude + ',' + position.coords.latitude); var srs_map = new openlayers.projection("epsg:25832"); var srs_lonlat = new openlayers.projection("epsg:4326"); var center = new openlayers.lonlat(position.coords.longitude,position.coords.latitude); var test = center.transform(srs_lonlat,srs_map); alert(test); }
finally map object:
map = new openlayers.map('map',{ controls: [ new openlayers.control.navigation(), new openlayers.control.panzoombar(), new openlayers.control.scaleline(), new openlayers.control.keyboarddefaults() ], projection: new openlayers.projection("epsg:25832"), displayprojection: new openlayers.projection("epsg:4326"), units: 'm', maxextent: new openlayers.bounds(356570.500,5442150.416,383807.687,5462691.920), maxresolution: 'auto', numzoomlevels: 8 });
i same coordinates back, no transformation @ all. position object lon , lat working fine, cannot openlayers transform function work properly. using newest standard openlayers.
i quite new openlayers please specific solution. in advance.
you need use proj4js. here's link instructions openlayers: http://trac.osgeo.org/openlayers/wiki/documentation/dev/proj4js. make sure add definition epsg:25832 instructed.
Comments
Post a Comment