Hi I am trying to set the projection of a SimpleMarkerOverlay but am unable. I am using Google maps and want to set it using the Proj4Projection code, but am unable. Specifically I am referencing the vehicle tracking example and trying to mod it to fit my needs.
Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
overlays.SimpleMarkerOverlay("Vehicles").Markers(markers =>
{
PointShape[] startPositions = TempData["InitPositions"] as PointShape[];
for (int i = 0; i < startPositions.Length; i++)
{
ThinkGeo.MapSuite.MvcEdition.WebImage webImage = new ThinkGeo.MapSuite.MvcEdition.WebImage(21, 25, -10.5f, -25f);
markers.Marker(startPositions.X, startPositions.Y, webImage).Id((i + 1).ToString());
}
});
Can you help me identify what I need to do to properly project that example on a Google map?
Thanks
Ashley
Setting Projection on SimpleMarkerOverlay
Hi Ashley,
Thanks for your post and welcome to MapSuite world!
Would you please try to use following code:
PointShape[] startPositions = TempData["InitPositions"] as PointShape[];
Collection<PointShape> projectedPositions = new Collection<PointShape>();
foreach (PointShape position in startPositions)
{ projectedPositions.Add(proj4.ConvertToExternalProjection(position) as PointShape); }
for (int i = 0; i < startPositions.Length; i++)
{
ThinkGeo.MapSuite.MvcEdition.WebImage webImage = new ThinkGeo.MapSuite.MvcEdition.WebImage(21, 25, -10.5f, -25f);
markers.Marker(startPositions.X, startPositions.Y, webImage).Id((i + 1).ToString());
}
now it should work, and if you have any more question , please feel free to let us know.
Best Regards
Summer
HI Summer,
Thank you so much for your reply. With the changes below I was able to get it to work. Thanks again!!!
overlays.SimpleMarkerOverlay("Vehicles").Markers(markers =>
{
PointShape[] startPositions = TempData["InitPositions"] as PointShape[];
Collection<PointShape> projectedPositions = new Collection<PointShape>();
proj4.Open();
foreach (PointShape position in startPositions)
{ projectedPositions.Add(proj4.ConvertToExternalProjection(position) as PointShape); }
proj4.Close();
for (int i = 0; i < startPositions.Length; i++)
{
ThinkGeo.MapSuite.MvcEdition.WebImage webImage = new ThinkGeo.MapSuite.MvcEdition.WebImage(21, 25, -10.5f, -25f);
markers.Marker(projectedPositions.X, projectedPositions.Y, webImage).Id((i + 1).ToString());
}
});
Hi Ashley,
Great to hear it helped, hope you could have a nice journey with MapSuite, and if you have any more question, please feel free to let us know.
Best Regards
Summer