GMap.Net Windows Mobile issue

Topics: Help, Windows Mobile
Sep 30, 2013 at 7:14 PM
Hi,

I am new in GMap.net.
Please help to remove this issue. whenever i add the reference of GMap.Net.Core.dll and GMap.Net.WindowsMobile.dll in .NET CF then i always got that issue.

Error 1 The type 'GMap.NET.PointLatLng' exists in both 'c:\Work\bin\GMap.NET.WindowsMobile.dll' and 'c:\Work\bin\GMap.NET.Core.dll'.

and there are on line in code.

map.Manager.Mode =GMap.NET.AccessMode.ServerOnly;
map.MapProvider =GMapProviders.GoogleMap;
map.Position = new PointLatLng(Variables.latitude, Variables.longitude);

Please help me to sort out this issue.

Regards

Waan Shela
Coordinator
Oct 1, 2013 at 7:49 AM
you don't need to reference GMap.NET.Core.dll for mobile project
Oct 6, 2013 at 9:23 PM
Thanks for the replying .

I am getting this error badly. Please help me sort out this.

"No Source code found"

"ObjectDisposedException"
at System.Threading.WaitHandle.CheckResultInternal(Boolean r)
at System.Threading.EventWaitHandle.Set()
at GMap.NET.Internals.Core.Dispose(Boolean disposing)
at GMap.NET.Internals.Core.Finalize()

My code

void timer_Tick(object sender, EventArgs e)
    {
      try
      {

          MakeMap();

        }
      catch (Exception ex)
      {
        updateTime.Enabled = false;            
      }
    }


private void makeMap()
    {
        panel1.Controls.Remove(MapControl);

        map = new GMapControl();
        map.Manager.Mode = GMap.NET.AccessMode.ServerOnly;
        map.MapProvider = GMapProviders.GoogleMap;
        map.MaxZoom = 17;
        map.MinZoom = 10;
        map.Zoom = map.MinZoom;

        map.Position = new PointLatLng(31.48035, 74.37417);

        OverlayOne = new GMapOverlay("OverlayOne");
        map.Overlays.Add(OverlayOne);

        GMapMarkerTransparentGoogleGreen driverMarker = new GMapMarkerTransparentGoogleGreen(map.Position);

        driverMarker.ToolTipMode = MarkerTooltipMode.Always;
        driverMarker.ToolTipText = "Driver";
        driverMarker.Tag = "Driver1";

        OverlayOne.Markers.Add(driverMarker);

        map.Size = new System.Drawing.Size(335, 245);

        panel1.Controls.Add(map);

    }
Coordinator
Oct 7, 2013 at 6:59 AM
why do you remove the control?
Oct 7, 2013 at 11:34 AM
Hi radioman,

Thanks for your reply.

I have changed my code and still i am getting the same issue.

I will explain you in more detail.

1) I am using .net CF 3.5 and Visual Studio 2008.
2) I have Window CE 6.0 Device.
3) I have created Map control in form constructor. Its working fine and creates the map and i desired.
3) I have a timer on my form as well which is updating my database with new coordinates if my position is changed.And i am making new marker at new position which is working fine.
4) I have few buttons in my form. Which are in separate panel then map control.

Issue Starts here:

In the start for 1 to 2 minutes its works fine but after sometime when I click on any button on my form or i just press on Map control and scroll the map or just click on zoom in and zoom out button it gives me the following error.


Error:-

"There is no source code available for the current location."

If click ok on message box then i got the following error.

"ObjectDisposedException"

Stack Trace:-

" at System.Threading.Timer.throwIfDisposed()\r\n at System.Threading.Timer.Change(UInt32 dueTime, UInt32 period)\r\n at System.Threading.Timer.Change(Int32 dueTime, Int32 period)\r\n at System.Net.HttpWebRequest.cancelReadWriteTimer()\r\n at System.Net.HttpWebRequest.ConnectionClient.Read(Byte[] data, Int32 offset, Int32 length)\r\n at System.Net.HttpReadStream.NetworkRead(Byte[] data, Int32 offset, Int32 length)\r\n at System.Net.ChunkedReadStream.fillBuffer()\r\n at System.Net.ChunkedReadStream.getLine()\r\n at System.Net.ChunkedReadStream.doRead(Byte[] data, Int32 offset, Int32 length)\r\n at System.Net.HttpReadStream.ReadToDrain(Byte[] buffer, Int32 offset, Int32 length)\r\n at System.Net.HttpReadStream.doClose()\r\n at System.Net.HttpReadStream.Finalize()\r\n"

Note:- I was thinking it may be due to of my web service. I removed all of the code except my map control code still the i got the error.

If i click continue on the above error then i got the following.

"ObjectDisposedException"

Stack Trace:-

" at System.Threading.WaitHandle.CheckResultInternal(Boolean r)\r\n at System.Threading.EventWaitHandle.Set()\r\n at GMap.NET.Internals.Core.Dispose(Boolean disposing)\r\n at GMap.NET.Internals.Core.Finalize()\r\n"



My Code:-


public partial class frmLocation:Form
{
    internal GMap.NET.WindowsForms.GMapControl map;
    internal GMapOverlay OverlayOne;

    System.Windows.Forms.Timer updateTime = new System.Windows.Forms.Timer();

    public frmDriverLocationNew()
    {
        InitializeComponent();

        updateTime.Tick += new EventHandler(timer_Tick);
        updateTime.Interval = (6000) * (10);
        updateTime.Enabled = true;


        //getting the coordinates
        ///new ClsGPS();

      //Start of Map
        map = new GMapControl();
        map.Manager.Mode = GMap.NET.AccessMode.ServerOnly;
        map.MapProvider = GMapProviders.GoogleMap;
        map.MaxZoom = 17;
        map.MinZoom = 12;
        map.Zoom = map.MinZoom;
        //map.Position = new PointLatLng(Variables.latitude, Variables.longitude);
        map.Position = new PointLatLng(31.48035, 74.37417);
        OverlayOne = new GMapOverlay("OverlayOne");
        map.Overlays.Add(OverlayOne);
        GMapMarkerTransparentGoogleGreen driverMarker = new GMapMarkerTransparentGoogleGreen(map.Position);
        //GMapMarkerImage image = new GMapMarkerImage(map.Position, imageList1.Images[0]); 
        driverMarker.ToolTipMode = MarkerTooltipMode.Always;
        driverMarker.ToolTipText = "Driver";
        driverMarker.Tag = "Driver1";
        OverlayOne.Markers.Add(driverMarker);
        map.Size = new System.Drawing.Size(335, 245);
        panel1.Controls.Add(map);           

    }
void timer_Tick(object sender, EventArgs e)
    {
      try
      {
          //getting coordinates
        ////new ClsGPS();

          MakeMap();     

      }

      catch (Exception ex)
      {
        updateTime.Enabled = false;
        MessageBox.Show(ex.ToString());
      }
    }

   private void MakeMap()
    {
        //getting the coordinates
       //// new ClsGPS();

        var m = OverlayOne.Markers.FirstOrDefault(p => (p.Tag as string) == "Driver1");
        if (m != null)
        {
            OverlayOne.Markers.Remove(m);
        }

        var pos = new PointLatLng(31.495030, 74.391257);
        GMapMarker marker = new GMapMarkerGoogleGreen(pos);
        {
            marker.ToolTipText = "Driver";
            marker.ToolTipMode = MarkerTooltipMode.Always;
            marker.Tag = "Driver1";
            // marker.Offset = new System.Drawing.Point(-marker.Size.Width, -marker.Size.Height);
        }

        OverlayOne.Markers.Add(marker);
        map.ReloadMap();
        map.Refresh();                
    }
}



Hope now you can understand my problem well.

Waiting for your reply.
Coordinator
Oct 7, 2013 at 12:55 PM
remove map.ReloadMap();
don't remove marker, reuse it
Oct 7, 2013 at 2:11 PM
Thanks for your reply i have changed my code as per ur advice.

I am still getting the same issues after sometime.

Waiting for your reply
Oct 7, 2013 at 2:15 PM
My new code is as fellow
public partial class frmDriverLocationNew :Form
    {
       
        internal GMap.NET.WindowsForms.GMapControl map;
        internal GMapOverlay OverlayOne;
        GMapMarkerTransparentGoogleGreen driverMarker;

        System.Windows.Forms.Timer updateTime = new System.Windows.Forms.Timer();

        public frmDriverLocationNew()
        {
            InitializeComponent();
           
            updateTime.Tick += new EventHandler(timer_Tick);
            updateTime.Interval = (6000) * (10);
            updateTime.Enabled = true;

            
            //getting the coordinates
            ///new ClsGPS();

            //Start of Map
            map = new GMapControl();
            map.Manager.Mode = GMap.NET.AccessMode.ServerOnly;
            map.MapProvider = GMapProviders.GoogleMap;
            map.MaxZoom = 17;
            map.MinZoom = 12;
            map.Zoom = map.MinZoom;
            //map.Position = new PointLatLng(Variables.latitude, Variables.longitude);
            map.Position = new PointLatLng(31.48035, 74.37417);
            OverlayOne = new GMapOverlay("OverlayOne");
            map.Overlays.Add(OverlayOne);
            driverMarker = new GMapMarkerTransparentGoogleGreen(map.Position);
            //GMapMarkerImage image = new GMapMarkerImage(map.Position, imageList1.Images[0]); 
            driverMarker.ToolTipMode = MarkerTooltipMode.Always;
            driverMarker.ToolTipText = "Driver";
            driverMarker.Tag = "Driver1";
            OverlayOne.Markers.Add(driverMarker);
            map.Size = new System.Drawing.Size(335, 245);
            panel1.Controls.Add(map);

            pbLoader.Visible = false;
            this.Refresh();

        }

        void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                //getting coordinates
                ////new ClsGPS();
              
                MakeMap();
            
            }
          
            catch (Exception ex)
            {
                updateTime.Enabled = false;
                MessageBox.Show(ex.ToString());
            }
           
        }
    

        private void MakeMap()
        {
            //getting the coordinates
           //// new ClsGPS();

            var pos = new PointLatLng(31.495030, 74.391257);
            driverMarker.Position = pos;
                       
            OverlayOne.Markers.Add(driverMarker);
            map.Refresh();
               
        }
}
Coordinator
Oct 7, 2013 at 2:19 PM
ObjectDisposedException?
Oct 7, 2013 at 2:23 PM
Same as i described above.

"There is no source code available for the current location."

If click ok on message box then i got the following error.

"ObjectDisposedException"

Stack Trace:-

" at System.Threading.Timer.throwIfDisposed()\r\n at System.Threading.Timer.Change(UInt32 dueTime, UInt32 period)\r\n at System.Threading.Timer.Change(Int32 dueTime, Int32 period)\r\n at System.Net.HttpWebRequest.cancelReadWriteTimer()\r\n at System.Net.HttpWebRequest.ConnectionClient.Read(Byte[] data, Int32 offset, Int32 length)\r\n at System.Net.HttpReadStream.NetworkRead(Byte[] data, Int32 offset, Int32 length)\r\n at System.Net.ChunkedReadStream.fillBuffer()\r\n at System.Net.ChunkedReadStream.getLine()\r\n at System.Net.ChunkedReadStream.doRead(Byte[] data, Int32 offset, Int32 length)\r\n at System.Net.HttpReadStream.ReadToDrain(Byte[] buffer, Int32 offset, Int32 length)\r\n at System.Net.HttpReadStream.doClose()\r\n at System.Net.HttpReadStream.Finalize()\r\n"


If i click continue on the above error then i got the following.

"ObjectDisposedException"

Stack Trace:-

" at System.Threading.WaitHandle.CheckResultInternal(Boolean r)\r\n at System.Threading.EventWaitHandle.Set()\r\n at GMap.NET.Internals.Core.Dispose(Boolean disposing)\r\n at GMap.NET.Internals.Core.Finalize()\r\n"
Coordinator
Oct 7, 2013 at 2:24 PM
well that's not the map issue
Oct 7, 2013 at 2:48 PM
Thanks for ur reply.

This issue is really disturbing my life.

Do u have skype id, i am ready to share the screen with you by using device emulator.

waiting for your reply
Coordinator
Oct 7, 2013 at 5:01 PM
fix your timer, it's not the map issue
Oct 8, 2013 at 7:09 PM
Hi,

I totally removed the timer and just click on zoom and zoom out button. get the same error my dear.

Oh GOD.

Please help me.
 private void btnZoomIn_Click(object sender, EventArgs e)
        {
            int zoom = (int)(map.Zoom);
            if (zoom >= 8)
            {
                //btnZoomIn.Enabled = true;
                map.Zoom = (int)(map.Zoom - 2);

            }
            else
            {
                //btnZoomIn.Enabled = false;
            }
            map.Refresh();
        }

        private void btnZoomOut_Click(object sender, EventArgs e)
        {
            int zoom = (int)(map.Zoom);
            if (zoom <= 8 || zoom >= 16)
            {
                //btnZoomOut.Enabled = false;
            }
            else
            {
               // btnZoomOut.Enabled = true;
                map.Zoom = (int)(map.Zoom + 1);
            }
            map.Refresh();
        }
Coordinator
Oct 9, 2013 at 7:24 AM
Edited Oct 9, 2013 at 7:25 AM
no need to call Refresh, anyway do you get the same error in demo?
Oct 9, 2013 at 10:35 PM
Edited Oct 9, 2013 at 10:36 PM
Hi radioman,

thanks for the reply, your demo code is working fine.

I am thinking to copy and past the same code which is not much different then my code, in my project and then try to test it.

Really thanks for your reply