ThinkGeo.com    |     Documentation    |     Premium Support

Display MapTools MouseCoordinate in Normal Lat Long

Hi,

I have a small issue in displaying mouse coordinates in my Thinkgeo Web edition application

We have already a featuere “MouseCoordinate” and its working fine with given code.
wfMap.MapTools.MouseCoordinate.MouseCoordinateType = MouseCoordinateType.LongitudeLatitude;
wfMap.MapTools.MouseCoordinate.Enabled = true;

But MouseCoordinate is displaying in some projection shown in below pic(Top right Corner).

But I wanted to display it like normal lat long format like 10,10

And here i am using Mercator projection
Proj4Projection _proj = new Proj4Projection();
_proj.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
_proj.ExternalProjectionParametersString = Proj4Projection.GetEsriParametersString(54004);

Please suggest me how to convert or resolve this…

Thanks,
Ashok

Hi,

I found some logic from Forum, but still it doesn’t work for me.

Please check the code…

function mapMouseOver(e) {
var sourceProj = new OpenLayers.Projection(“EPSG:54004”);
var targetProj = new OpenLayers.Projection(“EPSG:4326”);
var lonlat = wfMap.GetOpenLayersMap().getLonLatFromPixel(new OpenLayers.Pixel(e.clientX, e.clientY));
var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
var convertedP = OpenLayers.Projection.transform(point, sourceProj, targetProj);
var concatString = convertedP.x + “:” + convertedP.y;

        $('#MousePosition').text(concatString);
    }

Transform is not working…

Thanks,
Ashok

Hi Ashok,

The sample should works for you:

9095.zip (174.2 KB)

Regards,

Ethan

It’s working out. Thank you.

Ashok

Hi Ashok,

I am glad to hear that’s helpful.

Regards,

Ethan