drawing a route of 2000 points or more

Topics: General
Oct 15, 2012 at 12:21 PM
Edited Oct 15, 2012 at 12:21 PM

Hi,

I'm developing a program to show a route for a vehicle.

i want to know , could the GMAP.Net do this for me and how to do that?

just a sample app i need for testing the speed of the GMAP.NET

thanks

Coordinator
Oct 15, 2012 at 12:40 PM

just try, check the demos

Oct 15, 2012 at 1:36 PM
radioman wrote:

just try, check the demos

where can i download demos only?

Coordinator
Oct 15, 2012 at 3:40 PM

here ;}

Oct 15, 2012 at 5:54 PM

i added all of the markers

now i need to make contact between them using drawing lines between points

how could i draw lines between them?

thanks

Coordinator
Oct 15, 2012 at 6:22 PM

add the route

Oct 15, 2012 at 6:27 PM

i've added that as an overlay to gmap component.

but the route is polygon

i need just lines

Coordinator
Oct 15, 2012 at 6:37 PM

check the demo source

Oct 15, 2012 at 7:08 PM
radioman wrote:

check the demo source

what do you mean by demo source?

i have downloaded "greatmaps_197400b3a921.zip" from the source code section.

there is just a demo application which draws polygon.

would you please tell me which parts you mean by demo?

thanks

Coordinator
Oct 15, 2012 at 7:51 PM

'Add Route' button

Oct 16, 2012 at 6:20 AM
radioman wrote:

'Add Route' button

 

i have done this way:

        internal readonly GMapOverlay objects = new GMapOverlay("objects");
        internal readonly GMapOverlay routes = new GMapOverlay("routes");

        public Form1()
        {
            InitializeComponent();

            gMapControl1.MapProvider = GMapProviders.GoogleMap;
            gMapControl1.Position = new PointLatLng(32.6961334816182, 52.2985095977783);
            gMapControl1.MinZoom = 0;
            gMapControl1.MaxZoom = 24;
            gMapControl1.Zoom = 9;
            gMapControl1.Overlays.Add(routes);
            gMapControl1.Overlays.Add(objects);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            List<PointLatLng> list = new List<PointLatLng>();

            // fill the list

            GMapRoute r = new GMapRoute(list, "my route");
            r.IsHitTestVisible = true;
            routes.Routes.Add(r);
            gMapControl1.ZoomAndCenterRoute(r);
        }

markers shows on map but there is no connection line between them!

i want to make my (offline) passed route visible on map!

and another thing, i have used my own rotated bitmap for my markers to show the direction, but the resulted markers have offset from the original position on map

why?

thanks

Coordinator
Oct 16, 2012 at 8:39 AM

route should be correct, and for markers if you rotate it, rotate it at the center

Oct 16, 2012 at 8:50 AM
radioman wrote:

route should be correct, and for markers if you rotate it, rotate it at the center

what you mean by correct?

the path is correct. and got from the GPS device

i only want to draw a line between the points.

i rotate the bitmap marker around the center of it.

Oct 16, 2012 at 9:51 AM

this is my route points

32.710525233333,51.709773683333
32.711725983333,51.704725066667
32.712161566667,51.7016886
32.71156525,51.700573083333
32.711619183333,51.697707483333
32.711683333333,51.693647033333
32.713998866667,51.69232
32.716209366667,51.69141195
32.716029866667,51.6902065
32.715211833333,51.687279733333
32.714487533333,51.684649283333
32.7138501,51.682203766667
32.713188,51.6800163
32.712567716667,51.677681383333
32.712951733333,51.676638066667
32.71328285,51.675441133333
32.713514866667,51.67297225
32.713735066667,51.670455
32.713785566667,51.66982365
32.713969216667,51.6673657

could you please make a route with these points and give me the code?

thanks

Oct 16, 2012 at 9:53 AM

and this is my rotation code:

 public Bitmap RotateImage(Image img, int rotationAngle)
        {
            // When drawing the returned image to a form, modify your points by 
            // (-(img.Width / 2) - 1, -(img.Height / 2) - 1) to draw for actual co-ordinates.

            //create an empty Bitmap image 
            Bitmap bmp = new Bitmap((img.Width), (img.Height));

            //turn the Bitmap into a Graphics object
            Graphics gfx = Graphics.FromImage(bmp);

            //set the point system origin to the center of our image
            gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2);

            //now rotate the image
            gfx.RotateTransform(rotationAngle);

            //move the point system origin back to 0,0
            gfx.TranslateTransform(-(float)bmp.Width / 2, -(float)bmp.Height / 2);

            //set the InterpolationMode to HighQualityBicubic so to ensure a high
            //quality image once it is transformed to the specified size
            gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

            //draw our new image onto the graphics object with its center on the center of rotation
            gfx.DrawImage(img, 0, 0);

            //dispose of our Graphics object
            gfx.Dispose();

            //return the image
            return bmp;
        }

Coordinator
Oct 16, 2012 at 10:24 AM

 

         List<PointLatLng> list = new List<PointLatLng>();

         list.Add(new PointLatLng(32.710525233333, 51.709773683333));
         list.Add(new PointLatLng(32.711725983333, 51.704725066667));
         list.Add(new PointLatLng(32.712161566667, 51.7016886));
         list.Add(new PointLatLng(32.71156525, 51.700573083333));
         list.Add(new PointLatLng(32.711619183333, 51.697707483333));
         list.Add(new PointLatLng(32.711683333333, 51.693647033333));
         list.Add(new PointLatLng(32.713998866667, 51.69232));
         list.Add(new PointLatLng(32.716209366667, 51.69141195));
         list.Add(new PointLatLng(32.716029866667, 51.6902065));
         list.Add(new PointLatLng(32.715211833333, 51.687279733333));
         list.Add(new PointLatLng(32.714487533333, 51.684649283333));
         list.Add(new PointLatLng(32.7138501, 51.682203766667));
         list.Add(new PointLatLng(32.713188, 51.6800163));
         list.Add(new PointLatLng(32.712567716667, 51.677681383333));
         list.Add(new PointLatLng(32.712951733333, 51.676638066667));
         list.Add(new PointLatLng(32.71328285, 51.675441133333));
         list.Add(new PointLatLng(32.713514866667, 51.67297225));
         list.Add(new PointLatLng(32.713735066667, 51.670455));
         list.Add(new PointLatLng(32.713785566667, 51.66982365));
         list.Add(new PointLatLng(32.713969216667, 51.6673657));

         GMapRoute r = new GMapRoute(list, "my route");
         r.Stroke.Width = 22;
         r.Stroke.Color = Color.Red;

         routes.Routes.Add(r);
         MainMap.ZoomAndCenterRoute(r);

 

Oct 16, 2012 at 10:37 AM
Edited Oct 16, 2012 at 10:37 AM

thanks

now the only problem is rotating the bitmap

i don't know why in my program rotation is not working while in the attached program rotation is working fine!

https://hotfile.com/dl/176275791/6f0a1a4/WindowsFormsApplication3.rar.html

Coordinator
Oct 16, 2012 at 10:48 AM

did you call map.Invalidate() after rotating the marker image?

Oct 16, 2012 at 10:49 AM
radioman wrote:

did you call map.Invalidate() after rotating the marker image?

no! should i do that?

Coordinator
Oct 16, 2012 at 10:52 AM

depends, i don't know what are you doing there ;}

Oct 16, 2012 at 10:58 AM

ok thanks

problem solved

i have to make a new instance of the image from the resource.

thanks

Oct 16, 2012 at 11:00 AM
Edited Oct 16, 2012 at 11:06 AM

now the rotation is ok

thanks

but

the place of the image is not correct

it has a offset to the route i've created

the route is really correct but the markers are not

when i use GMarkerGoogleType.arrow for the icon, its correct

why?

Coordinator
Oct 16, 2012 at 11:09 AM

set:

Size = new System.Drawing.Size(Bitmap.Width, Bitmap.Height);
Offset = new Point(-Size.Width / 2, -Size.Height);

Oct 16, 2012 at 11:21 AM
radioman wrote:

set:

Size = new System.Drawing.Size(Bitmap.Width, Bitmap.Height);
Offset = new Point(-Size.Width / 2, -Size.Height);

with the code below, my problem solved

m.Size = new System.Drawing.Size(bmp.Width, bmp.Height);
m.Offset = new Point(-bmp.Width / 2, -bmp.Height / 2);

Coordinator
Oct 16, 2012 at 11:37 AM

good ;}

Oct 29, 2012 at 9:20 AM

Thankyou , both of you, your Above discussion helped me a lot. :-)

Oct 29, 2012 at 9:36 AM
naveed161 wrote:

Thankyou , both of you, your Above discussion helped me a lot. :-)

;)

Feb 26, 2013 at 10:13 AM
Hi,

I am also looking for Vehicle Routing using GMAP.Net. Is it possible? where can i download demos?

Thanks
VS
Coordinator
Feb 26, 2013 at 1:49 PM
in the download section