You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Overview

This page has information about the map components.

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.

On this page:


System Requirements

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

  • Product version v8.1.39 or newer.



How to Use a GMapControl

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 go to the Display Drawing section in the Drawing tab, and click Insert a Component.

Insert Component button location



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


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 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 GMap proprieties, you need to configure the mouse and other settings.

All these codes are in method DisplayOpening () {} and in 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 = 1;
gmap.AutoScroll = true;

// Choose the provider:

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


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

//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:

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:

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 () {}

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);	

  }

In this section...

The root page @parent could not be found in space v10.

  • No labels