Dear Support Team,
I used below codes to overlay shape file layer to OpenStreetMap. The shape file shifts a little bit from OSM, see attachment A1-Program result.
ShapeFileFeatureLayer roads = new ShapeFileFeatureLayer(OPUSParams.shapedir + “\” + OPUSParams.mileage_database + “-roads_” +
OPUSParams.road_network_timestamp + “.shp”,OPUSParams.shapedir + “\” + OPUSParams.mileage_database + “-roads_” + OPUSParams.road_network_timestamp + “-highways2.idx”);
Proj4Projection prj4 = new Proj4Projection();
prj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(2957);
rj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
prj4.Open();
roads.FeatureSource.Projection = prj4;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add(“roads”, roads);
winformsMap1.Overlays.Add(staticOverlay);
winformsMap1.MapUnit = GeographyUnit.Meter;
OpenStreetMapOverlay osmOvelerlay = new OpenStreetMapOverlay();
winformsMap1.Overlays.Add(osmOvelerlay);
winformsMap1.Overlays.MoveToBottom(winformsMap1.Overlays.IndexOf(osm));
winformsMap1.ZoomLevelSet = new OpenStreetMapsZoomLevelSet();
winformsMap1.Refresh();
However, I overlaid this shape file to OpenStreetMap in QGIS, and they matched well, see attachment A2-GIS Result. The SHR-roads_01_08_2013.zip is the shape file I used.
Thanks so much.
Michael Ma, PhD, EIT
Senior Geomatics Scientist
Western Heritage
322 Duchess St. Saskatoon, SK
Office: 1-306-975-3860,312
Mobile: 1-306-341-4916
Web: westernheritage.ca
A1-Program_result.jpg (74.9 KB)
A2-GIS_Result.jpg (65.8 KB)
SHR-roads_01_08_2013.zip (1.06 MB)
Open Street Map & Shape file overlay do not match well
Hi Michael,
I tested with your code and shape file, it looks we render correct with our latest dll.
Could you please let me know which version are you using?
As below is my test code:
private void ShowHideLayer_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.Meter;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@“D:\SHR-roads_01_08_2013\SHR-roads_01_08_2013.shp”);
ShapeFileFeatureLayer.BuildIndexFile(@“D:\SHR-roads_01_08_2013\SHR-roads_01_08_2013.shp”, BuildIndexMode.DoNotRebuild);
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad4;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Proj4Projection prj4 = new Proj4Projection();
prj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(2957);
prj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
prj4.Open();
worldLayer.FeatureSource.Projection = prj4;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add(“roads”, worldLayer);
winformsMap1.Overlays.Add(staticOverlay);
winformsMap1.MapUnit = GeographyUnit.Meter;
OpenStreetMapOverlay osmOvelerlay = new OpenStreetMapOverlay();
winformsMap1.Overlays.Add(osmOvelerlay);
winformsMap1.Overlays.MoveToBottom(winformsMap1.Overlays.IndexOf(osmOvelerlay));
winformsMap1.ZoomLevelSet = new OpenStreetMapsZoomLevelSet();
winformsMap1.CurrentExtent = new RectangleShape(-11864853.5418082, 6818455.81236492, -11863969.7408793, 6817825.20845891);
winformsMap1.Refresh();
}
Regards,
Don
Hi Don,
Thanks very much.
My version is 5.5. When I zoom in or zoom out, it does not match well.
What about you when you zoom in or zoom out using the latest version?
Michael
Hi Michael,
I tested to zoom in and out, the road still match well.
Sorry I haven’t found 5.5 dll so I cannot test that, could you please download a trial version of new 8.0 dll and have a look whether that works for you?
And if possible, could you please use my code and your 5.5 version dll test together, so that we can make sure whether this exception is caused by other code in your project.
Regards,
Don
Hi Don,
Thanks for your quick response.
I tested your source code in V5.5 and V8. It worded well in V8, not in V5.5. It should be the version issue.
As well, I used my data and the below code to import Google Map. It did not match well.
winformsMap1.MapUnit = GeographyUnit.Meter;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));
GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay();
winformsMap1.Overlays.Add(googleMapsOverlay);
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@“D:\OpusTrack 9\SHR-roads_01_08_2013\SHR-roads_01_08_2013.shp”);
ShapeFileFeatureLayer.BuildIndexFile(@“D:\OpusTrack 9\SHR-roads_01_08_2013\SHR-roads_01_08_2013.shp”, BuildIndexMode.DoNotRebuild);
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad4;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Proj4Projection prj4 = new Proj4Projection();
prj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(2957);
prj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
prj4.Open();
worldLayer.FeatureSource.Projection = prj4;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add(“roads”, worldLayer);
winformsMap1.Overlays.Add(staticOverlay);
//Sets the extent of the map as the bounding box of the shapefile layer as projected (Google Map Spherical Mercator).
worldLayer.Open();
winformsMap1.CurrentExtent = worldLayer.GetBoundingBox();
worldLayer.Close();
winformsMap1.Refresh();
Michael
Hi Michael,
It looks the GoogleOverlay’s tile have some problem.
Could I know are you testing 5.5 or 8.0 here?
And maybe you can try to set googleMapsOverlay.TileMode = GoogleMapsTileMode.SingleTile; to see whether they can match.
Regards,
Don
Hi Don,
I used 8.0 in this test. If I set googleMapsOverlay.TileMode = GoogleMapsTileMode.SingleTile, the resut is below. Thanks for your time and help.
–Michael
Hi Michael,
Today I tested your code with GoogleOverlay, it looks works well and match well both under Multiply / Single Tile mode.
From your screen shots I thought it should caused by cache but I haven’t found related code in your reply.
So could you please upload your latest test program(without data and dll) and let us know your detail ThinkGeo dll version(8.0.x.x)?
I want to reproduce that first.
Regards,
Don
Hi Don,
The version should be V8.0.0.0. I downloaded it from: thinkgeo.com/map-suite-developer-gis/desktop-edition/
The codes are:
//We need to set the map unit to meter because we are using Google Map Spherical Mercator projection.
winformsMap1.MapUnit = GeographyUnit.Meter;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));
//Sets Google Map as the background map.
GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay();
googleMapsOverlay.TileMode = GoogleMapsTileMode.MultiTile;
winformsMap1.Overlays.Add(googleMapsOverlay);
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"D:\OpusTrack 9\SHR-roads_01_08_2013\SHR-roads_01_08_2013.shp");
ShapeFileFeatureLayer.BuildIndexFile(@"D:\OpusTrack 9\SHR-roads_01_08_2013\SHR-roads_01_08_2013.shp", BuildIndexMode.DoNotRebuild);
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad4;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Proj4Projection prj4 = new Proj4Projection();
prj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(2957);
prj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
prj4.Open();
worldLayer.FeatureSource.Projection = prj4;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add("roads", worldLayer);
winformsMap1.Overlays.Add(staticOverlay);
winformsMap1.CurrentExtent = new RectangleShape(-11864853.5418082, 6818455.81236492, -11863969.7408793, 6817825.20845891);
winformsMap1.Refresh();
Thanks very much,
Michael
Hi Michael,
The code you pasted don’t have problem, it still matchwell in my machine. My test dll version is 8.0.0.9.
I want to test your test project because I thought maybe there is some other code related with that.
If you make sure you don’t have any other code about this, could you please test your project in another machine which have installed our eval 8.0 also?
Regards,
Don
Hi Michael,
I got the cause of this issue. I think it must be a error on system display settings. You can check your system display settings as following diagram:
Control panel -> Display:
If you take 125% option, you just get following diagram:
So, I think you will take the correct option 100% for your display settings.
Thanks
Don
Hi Don,
You are correct. Well done. It matched well after I adjusted the configuration. Thanks very much for your swift answer.
I’m discussing with our manager to purchase your product.
Michael
Hi Michael,
I am glad to hear that works for you.
Welcome to use our product, any question please let us know.
Regards,
Don
Hi Don,
I used the below code to add the text style to map: healthArea.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(TextStyles.CreateSimpleTextStyle(“Name”, “Arial”, 10.0f, DrawingFontStyles.Underline, GeoColor.FromArgb(60, 200, 230, 255)));
healthArea.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
But the text on the map did not look clearly (see attachment). Thanks very much,
Michael
text_Style.png (52.5 KB)
Hi Michael,
Seems the font color on the image is not match what you set in code, would you please modify the TextRenderingHint Property of WinformsMap from SystemDefault to AntiAlias?
If the above doesn’t help, Would you please attach a more clear screenshot to show the issue or a sample is better?
Hope it helps.
Thanks,
Hi Mapsuite Support,
It did not make difference setting SystemDefault or AntiAlias. The font style looks good via: healthArea.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(TextStyles.CreateSimpleTextStyle("Name", "Aerial", 8.0f, DrawingFontStyles.Regular, new GeoColor(0, 0, 0), new GeoColor(255, 0, 0),0.5f, 2.0f, 1.0f));
I can use this method now. Thanks very much.
Michael
Hi Michael,
I am glad to hear that works for you.
Regards,
Don