Quantcast
Channel: GMap.NET - Great Maps for Windows Forms & Presentation
Viewing all 3384 articles
Browse latest View live

New Post: Unmanaged code in gmap

$
0
0
Hi.
Is there unmanaged code in gmap (for example something with Win32 etc.)? The matter is I have to use my winforms application in various operating systems.

New Post: SetPositionByKeywords only centers on screen

$
0
0
This is a strange problem that I just do not understand. I of the opinion that it might be my machine (so hoping I am wrong). My mapping program was working fine with this great tool. Yesterday things went wonky.

On my development machine, I can not use SetPositionByKeywords at all. It doesn't matter what location I use ("Seattle, WA USA", "Dallas, TX USA", "855 West Alexis Street, Toledo, OH") or what zoom level (10, 14, 18 have all been tried). Regardless of what I put all the map will do is go to the zoom level I have set and zoom to whatever the center of the map itself is at when I push the button.

This is where it gets wonky. If I compile the program and install it on another machine the SetPositionByKeywords works exactly as expected. And if I install it on my development machine it works fine. However, when running through Visual Studio 2015, SetPositionByKeywords does not work. It just centers on the screen to the zoom level I set.

Has anyone else experienced anything like this? Does anyone have any ideas on how to fix this?

New Post: Google Maps Directions - Added Waypoints

$
0
0
Hello, i'm using poter134 snippet of code to solve cvsp problem
     GMapOverlay ovl = new GMapOverlay("MyTestOverlay");
                GMapRoute rte = new GMapRoute("MyTestRoute");

                GDirections _dir;
                DirectionsStatusCode _code = GMapProviders.GoogleMap.GetDirections(out _dir, startPoint, myWaypoints, false, false, false, false, true);
                if (_code == DirectionsStatusCode.OK)
                {
                    foreach (GDirectionStep _step in _dir.Steps)
                    {
                        rte.Points.AddRange(_step.Points);
                    }
                }
but the _code variable return ExceptionInCode
I'm amateur in programming.

Created Unassigned: I cant get satellite map provider [16153]

$
0
0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using GMap.NET.MapProviders;
using GMap.NET;


namespace ISR
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
gMapControl1.MapProvider = GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
gMapControl1.DragButton = MouseButtons.Left;
gMapControl1.CanDragMap = true;
gMapControl1.Position = new PointLatLng(39.81692, 30.52686);
gMapControl1.MinZoom = 2;
gMapControl1.MaxZoom = 18;
gMapControl1.Zoom = 18;
gMapControl1.AutoScroll = true;
}
}
}


I am using above code but satellite images cant be seen. there is an error.

Commented Unassigned: I cant get satellite map provider [16153]

$
0
0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using GMap.NET.MapProviders;
using GMap.NET;


namespace ISR
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
gMapControl1.MapProvider = GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
gMapControl1.DragButton = MouseButtons.Left;
gMapControl1.CanDragMap = true;
gMapControl1.Position = new PointLatLng(39.81692, 30.52686);
gMapControl1.MinZoom = 2;
gMapControl1.MaxZoom = 18;
gMapControl1.Zoom = 18;
gMapControl1.AutoScroll = true;
}
}
}


I am using above code but satellite images cant be seen. there is an error.
Comments: what error? You are not helping me.

New Post: Choose between faster or shorter route

$
0
0
Hi,

What il the way to choose the faster route, which use highway as soon as possible ?

By default, it seems that the shorter way is always selected. Setting, the option
avoid highway to false don't change.


Thanks in advance

New Post: Tried adding new map provider, running into issues.

$
0
0
I tried adding a new map provider (GeoPortail, see below)
And it seems to be working for the most part, except that sometimes when i zoom in it does not grab the imagery. I have to switch map type and switch back before it starts grabbing again.
I am not sure if I did something wrong.
  string MakeTileImageUrl(GPoint pos, int zoom, string language)
  {
     // http://m3.mapserver.mapy.cz/ophoto-m/14-8802-5528
     // https://wxs.ign.fr/an7nvfzojv5wa96dsga5nk8w/geoportail/wmts?layer=ORTHOIMAGERY.ORTHOPHOTOS&style=normal&tilematrixset=PM&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fjpeg&TileMatrix=19&TileCol=264884&TileRow=187337

     return string.Format(UrlFormat, zoom, pos.Y, pos.X);
  }

  static readonly string UrlFormat = "https://wxs.ign.fr/an7nvfzojv5wa96dsga5nk8w/geoportail/wmts?layer=ORTHOIMAGERY.ORTHOPHOTOS&style=normal&tilematrixset=PM&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fjpeg&TileMatrix={0}&TileCol={2}&TileRow={1}";

New Post: Exception when switching providers

$
0
0
Zoom in to florida, USA and switch to the swedish map. It will come up with exception at:
    public override GSize GetTileMatrixMinXY(int zoom)
    {
        if (extentMatrixMin == null)
        {
            GenerateExtents();
        }
        return extentMatrixMin[zoom];
    }
in SWEREF99_TMProjection.cs

New Post: TilePrefetcher process

$
0
0
krisket,

could you elaborate? that was a really vague solution you provided, and not so helpful. I am encountering something similar but post is currently a dead end.

any code snippets would be really good.

New Post: Drawing A Circle

$
0
0
Hi All,

I'm learning GMap for use in a project and I'm pretty new to C#. I have run into a problem and I'd be grateful for a little help if possible.

This is the code I'm using
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using GMap.NET;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;
using GMap.NET.MapProviders;
using System.Drawing.Drawing2D;

namespace GMapTest2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public class GMapMarkerCircle : GMapMarker
        {
            public int Radius;
            public Pen OutlinePen;
            public Brush FillBrush;
            public bool Fill;

            public GMapMarkerCircle(PointLatLng p)
                : base(p)
            {
                OutlinePen = new Pen(Brushes.Orange, 2);
                FillBrush = new SolidBrush(Color.FromArgb(60, Color.Orange));
                Radius = 0;
            }

            public override void OnRender(Graphics g)
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;

                int R = (int)((Radius) / Overlay.Control.MapProvider.Projection.GetGroundResolution((int)Overlay.Control.Zoom, Position.Lat)) * 2;

                if (Fill == true)
                {
                    g.FillEllipse(FillBrush, new System.Drawing.Rectangle(LocalPosition.X - R / 2, LocalPosition.Y - R / 2, R, R));
                }
                g.DrawEllipse(OutlinePen, new System.Drawing.Rectangle(LocalPosition.X - R / 2, LocalPosition.Y - R / 2, R, R));
            }
        }



        private void gmap_Load(object sender, EventArgs e)
        {
            // Selects the provider and loads the map
            gmap.MapProvider = OpenStreetMapProvider.Instance;
            GMapProvider.UserAgent = "";
            GMaps.Instance.Mode = AccessMode.ServerOnly;


            // Sets initial position of the map
            gmap.SetPositionByKeywords("EGBB, UK");
            //EGBB 52.4524, 1.7435
            //gmap.Position = new GMap.NET.PointLatLng(52.4524, -1.7435);




            //  Full code that creates a marker
            GMapOverlay markers = new GMapOverlay("markers");
            GMapMarker marker = new GMarkerGoogle(new PointLatLng(52.45, -1.74), GMarkerGoogleType.yellow_dot);
            markers.Markers.Add(marker);
            gmap.Overlays.Add(markers);



            // Full code that creates polygons
            GMapOverlay polygons = new GMapOverlay("polygons");
            List<PointLatLng> points = new List<PointLatLng>();
            points.Add(new PointLatLng(52.487, -1.731));  // top left
            points.Add(new PointLatLng(52.488, -1.696));  // top right
            points.Add(new PointLatLng(52.469, -1.695));  // bottom right
            points.Add(new PointLatLng(52.468, -1.732));  // bottom left
            GMapPolygon polygon = new GMapPolygon(points, "JCT 7a");
            polygons.Polygons.Add(polygon);
            gmap.Overlays.Add(polygons);
            polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
            polygon.Stroke = new Pen(Color.Red, 1);



            // Full code to show a route
            GMapOverlay routes = new GMapOverlay("routes");
            List<PointLatLng> point = new List<PointLatLng>();
            point.Add(new PointLatLng(52.485, -1.809));
            point.Add(new PointLatLng(52.412, -1.779));
            point.Add(new PointLatLng(52.437, -1.649));
            GMapRoute route = new GMapRoute(point, "Route Test");
            route.Stroke = new Pen(Color.Blue, 3);
            routes.Routes.Add(route);
            gmap.Overlays.Add(routes);



            // Full code to show a circle
            GMapOverlay circleTest = new GMapOverlay("circleTest");
            gmap.Position = new PointLatLng(52.478, -1.653);
            GMapMarkerCircle gmc = new GMapMarkerCircle(gmap.Position);
            gmc.Radius = 2500;
            gmc.IsVisible = true;
            gmap.Overlays.Add(circleTest);
        }
    }
}
I don't seem to be able to post the result but the marker, polygon and the route all show as expected but the circle does not. Unfortunately I'm not able to understand what I have done wrong. I would be grateful if anyone could show me what the error is. Many thanks

New Post: GMap.Net - Get Duration and Cities

$
0
0
Hi. I'm trying to develop a windows Form Project using GMap (Google Map Provider) and I have some questions.
  1. Is there any way to get duration of my route?
  2. Is there any way to get other cities on my route?
    thanks for help.

New Post: Multi-Touch zoom in WPF

New Post: Routing

$
0
0
Hi

I need my route to avoid highways\motorways setting highway to false does not seem to avoid them Need help

Cheers

New Post: Moving a marker based on the current time

$
0
0
Hello everyone.

First time poster here so go easy. I'am currently working on an application using visual studio 2012 C# that is meant show the routes of busses operated by the Translink company in Northern Ireland, specifically around Belfast.

So far, I've got a windows form that displays a map of the area in Google Maps and a few buttons, 3 of which overlay red lines representing a certain bus route when clicked. These were created via a large number of latitude and longitude co-ordinates in the code for the form.

Want I want to do now however is to add a marker whenever a route is selected which then appears above it. Depending on the time of day, the marker will re-position itself onto another part of the route. This is to represent the bus as it moves along the route and to show its approximate location based on its timetable data from Translink. So say for example, a user selects a route for a bus travelling from Belfast to the town of Bangor. If the user selects the route at a certain time such as 2pm for example, it will show the marker representing the bus at the route's beginning. If the user shuts down and re-opens the program however and selects the same route at 3pm, then the marker should now be positioned somewhere near Bangor.

While I would be happy if the marker is static whenever the route is selected, I would also be happy if it could actively moving at all times.

If anyone has any knowledge/experience about this or knows of any guides/tutorials/programs in relation to this, please let me know.

Thanks very much.

Also, here is the code I currently have so far.
``` using GMap.NET;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;
using GMap.NET.MapProviders;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TransLinkProject_Test_Run
{
public partial class Form1 : Form
{


    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        gmap.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
        GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
        gmap.SetPositionByKeywords("Belfast, United Kingdom");

    }

    private void button1_Click(object sender, EventArgs e)
    {

        gmap.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
        GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
        gmap.SetPositionByKeywords("Belfast, United Kingdom");
        PointLatLng start = new PointLatLng(54.599564, -5.924172);
        PointLatLng end = new PointLatLng(54.602187, -5.922665);
        //points.Add(new PointLatLng(54.601503, -5.918491));
        MapRoute route = GMap.NET.MapProviders.GoogleMapProvider.Instance.GetRoute(start, end, false, false, 15);
        GMapRoute r = new GMapRoute(route.Points, "My route");          
        GMapOverlay routesOverlay = new GMapOverlay("routes");
        routesOverlay.Routes.Add(r);
        gmap.Overlays.Add(routesOverlay);
    }

    private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

     private void button1_Click_1(object sender, EventArgs e)
    {
        gmap.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
        GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
        GMapOverlay routes = new GMapOverlay("routes");
        List<PointLatLng> points = new List<PointLatLng>();
        points.Add(new PointLatLng(54.594490, -5.936217));//Europa bus station
        points.Add(new PointLatLng(54.595099, -5.936190));
        points.Add(new PointLatLng(54.595182, -5.934543));
        points.Add(new PointLatLng(54.595189, -5.934543));
        points.Add(new PointLatLng(54.597559, -5.923990));
        points.Add(new PointLatLng(54.600718, -5.924631));
        points.Add(new PointLatLng(54.600982, -5.923392));
        points.Add(new PointLatLng(54.600267, -5.923144));//Laganside Bus Station
        points.Add(new PointLatLng(54.600969, -5.923369));
        points.Add(new PointLatLng(54.601149, -5.922275));
        points.Add(new PointLatLng(54.600254, -5.921674));
        points.Add(new PointLatLng(54.600360, -5.919196));
        points.Add(new PointLatLng(54.600776, -5.913333));
        points.Add(new PointLatLng(54.600776, -5.913333));
        points.Add(new PointLatLng(54.600986, -5.910230));
        points.Add(new PointLatLng(54.600309, -5.909264));
        points.Add(new PointLatLng(54.597264, -5.885779));
        points.Add(new PointLatLng(54.596033, -5.876026));
        points.Add(new PointLatLng(54.595132, -5.867626));
        points.Add(new PointLatLng(54.594386, -5.847799));
        points.Add(new PointLatLng(54.594976, -5.831577));
        points.Add(new PointLatLng(54.594075, -5.824914));
        points.Add(new PointLatLng(54.594703, -5.816621));
        points.Add(new PointLatLng(54.595014, -5.814937)); //Dundonald hospital
        points.Add(new PointLatLng(54.594445, -5.804558));
        points.Add(new PointLatLng(54.594793, -5.801586));
        points.Add(new PointLatLng(54.595371, -5.791115));
        points.Add(new PointLatLng(54.594047, -5.774088));
        points.Add(new PointLatLng(54.597441, -5.771395));
        points.Add(new PointLatLng(54.600306, -5.763606));
        points.Add(new PointLatLng(54.600231, -5.756740));
        points.Add(new PointLatLng(54.603699, -5.751054));
        points.Add(new PointLatLng(54.604333, -5.743822));//Bradshaw Bree
        points.Add(new PointLatLng(54.602307, -5.735572));
        points.Add(new PointLatLng(54.601052, -5.733866));            
        points.Add(new PointLatLng(54.600418, -5.729607));
        points.Add(new PointLatLng(54.600685, -5.726496));
        points.Add(new PointLatLng(54.599380, -5.723363));
        points.Add(new PointLatLng(54.599107, -5.718417));
        points.Add(new PointLatLng(54.595863, -5.709253));
        points.Add(new PointLatLng(54.592320, -5.712279));
        points.Add(new PointLatLng(54.589075, -5.712418));
        points.Add(new PointLatLng(54.590306, -5.709468));//Scrabo Road
        points.Add(new PointLatLng(54.594445, -5.699914));//Newtownards Bus Station
        points.Add(new PointLatLng(54.593945, -5.697129));
        points.Add(new PointLatLng(54.593159, -5.697303));
        points.Add(new PointLatLng(54.593436, -5.699170));
        points.Add(new PointLatLng(54.593768, -5.699180));//Newtownards, Gibsons Lane
GMapRoute route = new GMapRoute(points, "Belfast-Newtownards");
        route.Stroke = new Pen(Color.Red, 3);
        routes.Routes.Add(route);
        gmap.Overlays.Add(routes);
        gmap.SetPositionByKeywords("Belfast, United Kingdom");

        gmap.ShowCenter = false;
    }
private void button6_Click(object sender, EventArgs e)
    {
        try
        {
            System.Diagnostics.Process.Start("http://www.translink.co.uk/Services/Ulsterbus-Service-Page/Timetables/#");
        }
        catch { }
    }

    private void button4_Click(object sender, EventArgs e)
    {

    }




}
}

New Post: Load GMDB cache file in windows form

$
0
0
Is there command to set path for GMDB file?

New Post: Polygon Labels

$
0
0
Hi

I have hundreds of polygons on my map is there a way to show the polygon name or label on them all , and switching it name off and on?

Cheers
Colin

New Post: Map rotates but not the labels

$
0
0
Hi. I am working on an aviation map. But I need to have to make it have track-up orientation. The only way to do is instead of rotating the airplane bug, rotate the map, right? Now that I am rotating the map, it rotates but not the labels (city names, states, etc). Is there a workaround this? I am trying to do track up. Thanks a bunch

New Post: Drawing A Circle

$
0
0
What are you trying to do? If you want to draw a circle, draw first and then convert the coords to lat long

New Post: Loading the Source Code in VS 2013 Edition

$
0
0
I have downloaded the latest version of the Code and specifically wanted to see if I can create a new type of marker for my requirements and when I am trying to load the solution by clicking on solution file -- GMap.NET.sln it complains of not having dotnet verison 2.0

I tried loading the solution by forcing it to change to dotnet version 4.5 but the project don't load at all.. Please help.

Thanks
Ramesh

New Post: How to handle a map redraw

$
0
0
Hi,

in my WPF application I have a map on a Tab:

Image

When I move to the other tab and back to the map, all markers disappear and, if I add a new one it is not displayed.
The code where I handle the makers is:
    private void Vm_OnNewMarkerChanged(GMap.NET.WindowsPresentation.GMapMarker Marker)
    {
      var idx = MainMap.Markers.IndexOf(Marker);

      if (idx >= 0)
        MainMap.Markers[idx] = Marker;
      else
        MainMap.Markers.Add(Marker);
    }
MainMap is:
  class Map : GMapControl
  {
  }
and in the Window.xaml:
<local:Map x:Name="MainMap" Grid.Column="1" Zoom="13" MaxZoom="24" MinZoom="1" />
public MainWindow(MainVM viewModel)
{
  try
  {
    _ViewModel = viewModel;
    _ViewModel.OnNewMarkerChanged += Vm_OnNewMarkerChanged;

    DataContext = _ViewModel;

    InitializeComponent();

    GMaps.Instance.UseRouteCache = true;
    GMaps.Instance.UseGeocoderCache = true;
    GMaps.Instance.Mode = AccessMode.ServerAndCache;

    MainMap.MapProvider = GMapProviders.OpenStreetMap;
    MainMap.CacheLocation = System.AppDomain.CurrentDomain.BaseDirectory;
    MainMap.ShowTileGridLines = false;
    MainMap.Manager.Mode = AccessMode.ServerAndCache;
    MainMap.DragButton = System.Windows.Input.MouseButton.Left;

    MainMap.MouseMove += new System.Windows.Input.MouseEventHandler(MainMap_MouseMove);
    MainMap.OnMapZoomChanged += MainMap_OnMapZoomChanged;
  }
  
}
I have to handle the map refresh in some particular way?
Viewing all 3384 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>