Moving a marker based on the current time

Topics: Feature Requests, General, Help, Windows Forms
Mar 1 at 4:15 AM
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)
    {

    }




}
}