How to add gmap programmatically in WPF?

Topics: Help, WPF
Sep 7, 2012 at 2:59 AM

I want to add gmap programmatically in WPF. I add the code below

GMapControl gmap = new GMapControl(); 

Grid grid = this.GetGrid();

Grid.SetColumn(gmap, 2);

grid.Children.Add(gmap);

But the grid shows nothing but a red cross in the middle. How can I make it work?

Thanks.

Coordinator
Sep 7, 2012 at 11:01 AM

by default control use dummy empty provider, use something ese:

GMapControl gmap = new GMapControl(); 
{
gmap.MapProvider = GMapProviders.OpenStreetMap;

gmap.MinZoom = 4;
gmap.MaxZoom = 17;
gmap.Zoom = gmap.MinZoom;
}

grid.Children.Add(gmap); 

Sep 8, 2012 at 2:30 AM

Thank you very much.

But it seems that I can't drag and zoom in/out the map. Should I make it listen to mouse event or sth. like that?

Coordinator
Sep 8, 2012 at 10:38 AM

default DragButton is right