Robert Campbell
Posts: 7
Joined: Wed Sep 28, 2005 11:27 pm

Centering Map

Tue Jun 20, 2006 7:01 pm

A new question: I calibrated my map (Im in the US) using the WGS84 grid in GPSstudio. Whenever I load the map, it centers on the upper left corner. How can I get it to center on the center of the map when I load it?

bokelund
Posts: 117
Joined: Tue Dec 20, 2005 11:41 am

RE: Centering Map

Thu Jun 22, 2006 3:11 pm

There is no feature to center the maplib in GpsTools Studio. However, you can center the map after you have loaded the maplib in GpsTools. Here is an example in C#.

Code: Select all

// Create a map. 
GpsViewNET.Map map = new GpsViewNET.Map();
				
// Open a maplib
map.Open("FileName.maplib");
				
// Get the mapData 
GpsViewNET.MapData mapData = map.MapLib.GetMapDataByIndex(1);
				
// Get the size of the mapdata. 
GpsViewNET.Point size = mapData.Size;
				
// Calculate the center point i pixel coordinates. 
GpsViewNET.Point pointCenter = new GpsViewNET.Point(size.X/2, size.Y/2);
				
// Transform the point to a position. 
GpsToolsNET.Position posCenter = map.Point2Position(pointCenter);
				
// Center the map's positon. 
map1.Position = posCenter;
	
// Update to see changes. 
map.Update();
Regards,
Bjorn Bokelund

Franson Support

Robert Campbell
Posts: 7
Joined: Wed Sep 28, 2005 11:27 pm

RE: Centering Map

Thu Jun 22, 2006 6:27 pm

I dont suppose you can send this through in vb.net...

Thanks by the way

bokelund
Posts: 117
Joined: Tue Dec 20, 2005 11:41 am

RE: Centering Map

Thu Jun 22, 2006 7:45 pm

Well sure. Here it is:

Code: Select all

' Create a map
Dim Map As GpsViewNET.Map

' Open a maplib
Map.Open("filename")

' Get the mapData 
Dim mapData As GpsViewNET.MapData = Map1.MapLib.GetMapDataByIndex(1)

' Get the size of the mapdata. 
Dim size As GpsViewNET.Point = mapData.Size

' Calculate the center point i pixel coordinates
Dim pointCenter As New GpsViewNET.Point
pointCenter.X = size.X / 2
pointCenter.Y = size.Y / 2

Dim posCenter As New GpsToolsNET.Position

' Transform the point to a position.
posCenter = Map1.Point2Position(pointCenter)
' Center the map's positon.
Map1.Position = posCenter

' Update to see changes.
Map1.Update()
Regards,
Bjorn Bokelund

Franson Support

fdaunis
Posts: 2
Joined: Wed Oct 22, 2008 9:58 pm
Location: Spain

RE: Centering Map

Wed Oct 22, 2008 10:08 pm

Hi,
i'm trying to get all center positions of a maplib file which contains 3 maps. Some center positions obtained was not correct.

If I separate the maps into one maplib file for each map, I obtain correct position;

Here's my code:

GpsViewNET.Map MapaTemporal = new GpsViewNET.Map();
MapaTemporal.Open(path_fitxer_maplib);

int i = 1;
while (i <= MapaTemporal.MapLib.MapDataCount)
{
GpsViewNET.MapData objMapData = MapaTemporal.MapLib.GetMapDataByIndex(i);

GpsViewNET.Point sizex = objMapData.Size;
GpsViewNET.Point point_center = new GpsViewNET.Point();
point_center.X = sizex.X / 2;
point_center.Y = sizex.Y / 2;

GpsToolsNET.Position position_center = new GpsToolsNET.Position();
position_center = MapaTemporal.Point2Position(point_center);

//print (float)position_center.Latitude;
//print (float)position_center.Longitude;



objMapData = null;
i = i + 1;
}

MapaTemporal.Close();


Regards,
F. Daunis

Return to “GpsTools”