The GMapControl component is used to create GIS projects. This need is a common requirement in projects with assets geo-location. This component allows an easy way to do this configuration.

System Requirements

To make use of this feature, the following system requirements need to be matched:

  • Product version v8.1.39



How to Use

The GMapControl is a simple window with a map that uses coordinates and gets map information by a provider, like Google Maps or Bing Maps.

Creating a GMapControl

To create a GMapControl component, you need to navigate to the Draw section in the Drawing Tab, and click on Insert Component.



In the popup window, select the GMapControl component, and click on OK.

Note: GMapControl is available only in the .Net display type.

GMapControl Configuration

The following settings are a basic way to use GMapControl without using Code Behind.


  • Control name: Used to rename the component. Makes it easier to find and reference when using the Code Behind to manage the proprieties.
  • Latitude: You need to complete this field with the Latitude that you want to see.
  • Longitude: You need to complete this field with the Longitude that you want to see.
  • Map Provider: Select the correct provider:
    • Bing Maps
    • Cloud Made
    • Google
    • Open Cycle
    • WikiMapia
    • Yahoo Maps

Code Behind Callback (Only for advanced Customization)

First, you must import all of the GMapControl proprieties and set some variables.

*	C#:
using GMap.NET;
using GMap.NET.MapProviders;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;
using GMap.NET.Internals;

double end_zoom;
TGMapControl mapControl = null;
GMapControl gmap = null;
GMarkerGoogle marker = null;


After importing all of the GMap proprieties, you need to configure the mouse and other settings.

All these codes are in method DisplayIsOpening () {}

*	C#:
mapControl = this.CurrentDisplay.GetControl("TGMapControl") as TGMapControl;
gmap = mapControl.GetControlRef();
gmap.DragButton = System.Windows.Forms.MouseButtons.Left;
gmap.CanDragMap = true;
gmap.MarkersEnabled = true;
gmap.Zoom = 11;
end_zoom = gmap.Zoom;
gmap.MaxZoom = 22;
gmap.MinZoom = 0;
gmap.AutoScroll = true;

 * Choice the provider:

gmap.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;


Now, we will set the position from the Map and configure the Markers.

*	C#:
	//Set Longitude and Latitude
		
gmap.Position = new GMap.NET.PointLatLng(-15.793888, -47.883487);

	//Creating Markers
	
	gmap.Overlays.Add(new GMapOverlay("Markers"));
	gmap.Overlays[0].Markers.Clear();
	gmap.ReloadMap();
	
addMarker(new PointLatLng(-15.7118595,-47.9107536), GMarkerGoogleType.purple_pushpin,
"DC", String.Format("{0}\n{1}", "DC", "Digital City")); 	
		
	addMarker(new PointLatLng(-15.81164,-47.950911), 
GMarkerGoogleType.purple_pushpin, 
"B", String.Format("{0}\n{1}", "B", "Brasilia"));	

addMarker(new PointLatLng(-15.7837743,-47.8957009), GMarkerGoogleType.purple_pushpin, 
"NS", String.Format("{0}\n{1}", "EN", "Nacional Stadium"));	

addMarker(new PointLatLng(-15.7507488,-47.9370287), GMarkerGoogleType.purple_pushpin, 
"NB", String.Format("{0}\n{1}", "NB", "North Brasilia"));


To connect one point to another in the map, use the code below:

*	C#:

	GMapOverlay routes = new GMapOverlay("routes");
	List<PointLatLng> points = new List<PointLatLng>();
	points.Add(new PointLatLng(-15.712199, -47.911240));
	points.Add(new PointLatLng(-15.722334, -47.910331));
	points.Add(new PointLatLng(-15.723553, -47.909480));
	points.Add(new PointLatLng(-15.724644, -47.907717));
	points.Add(new PointLatLng(-15.7411402, -47.9177745));
	points.Add(new PointLatLng(-15.756816, -47.927832));
	points.Add(new PointLatLng(-15.754628, -47.932072));
	points.Add(new PointLatLng(-15.755097, -47.933931));
	points.Add(new PointLatLng(-15.752753, -47.934598));
	points.Add(new PointLatLng(-15.7507488,-47.9370287));
	
	GMapRoute route = new GMapRoute(points, "DC_NB");
	route.Stroke = new System.Drawing.Pen(System.Drawing.Color.Green, 3) ;
	routes.Routes.Add(route);
	gmap.Overlays.Add(routes);
		
	points.Clear();	


To use small markers in the map without a Big Marker, use this code:

*	C#:

	addMarker(new PointLatLng(-15.772571, -47.937260), 
GMarkerGoogleType.green_small, "RE_Y", 
String.Format("{0}\n{1}", "RE_Y", "Circuit: yyyy"));
	
addMarker(new PointLatLng(-15.775202, -47.938166), 
GMarkerGoogleType.green_small, "RE_z", 
String.Format("{0}\n{1}", "RE_z", "Circuit: zzzz"));


After this, the only thing left to do is to implement the method addMarker () {}

*	C#:
		public void addMarker(PointLatLng position, GMarkerGoogleType tipoPin, 
			string tag, string tooltipText)
{
	marker = new GMarkerGoogle(position, tipoPin);
	
	marker.Tag = tag;
	marker.ToolTipText = tooltipText;
	marker.ToolTip.Fill = System.Drawing.Brushes.Blue;
	marker.ToolTip.Foreground = System.Drawing.Brushes.White;
	marker.ToolTip.Stroke = System.Drawing.Pens.Black;
	marker.ToolTip.TextPadding = new System.Drawing.Size(20, 20);															
	marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;	
					
	gmap.Overlays[0].Markers.Add(marker);	

  }
  • No labels