Hi,
I’m having a problem with changing the projection of the map. If I use WGS84 the points in the loaded shapefiles display in the correct place, but, if I change to Google_mercator the points all end up in a block at the equator on the Grenwich meridian.
Am I missing something or doing something wrong?
It sounds like the points themselves are in DMS (is there a PRJ file?), and thus are located properly in WGS84. If you just change the projection of the map, the points are then interpreted by the map projection, so instead of a point being 40 degrees north, the point would be displayed 40 meters north (of the equator) since Google Mercator is in meters.
What you probably want to do is tell the map to reproject the layers on-the-fly at load time. Before you load the layer, set the Global property ReprojectLayersOnAdding = true, something like.
GlobalSettings gs = new GlobalSettings();
gs.ReprojectLayersOnAdding = true;
It may well be that without a PRJ file, the reproject-on-load won’t know what to do. Other options would be to either create a PRJ to go the with the Shapefile, or to programmatically set the projection (using the GeoProjection class) to the ‘known’ WGS84, then call the either the Reproject or ReprojectInPlace method.
Let me know if you need more specific direction regarding this.
Hi Jerry,
I tried ReprojectLayersOnAdding but it was painfully slow reprojecting the shapes on app start and is unworkable for my needs.
I have been thinking about copying the shapefile and reprojecting the copy in the background. That way when the user changes projection, all I have to do is load the associated shapes with the right projection. Any suggestions how I should do that?
I don’t know your particular use-case, or if indeed the user is regularly ‘changing’ the projection, but if you want to set up a process by which you can reproject the layer, without first loading the layer, you could try using the Utils class function, ReprojectShapefile. Hope that helps.
Just one more question what do I put in for the Projection when I reproject the shapes?
I can’t seem to find any reference to the GeoProjection in the help or the header file.
I’m going from WGS84 to Google Mercator.