starting on windows forms?

Topics: Windows Forms
Jun 26, 2011 at 6:43 AM

hi!

I've just found this control and looks awesome. I want to use it but i have some difficulties.

I've added the references to BSE.Windows.Forms, GMat.Net.Core and Gmap.Net.Windows.Forms to my project. I've added the component GmapControl to the toolbar, and dropped one on my form. I start the app and the window looks empty. what am i missing? is there a demo implementation? I've looked around and i couldn't find any.

 

Regards!

Coordinator
Jun 26, 2011 at 10:52 AM

hey ;}

..first remove BSE.Windows.Forms, it's only demo related, and the next thing would be to set position and define min/max zooms, and if you use release version, put two folders x86/x64 with sqlite dlls to our project output, just like in demos

Jun 26, 2011 at 3:50 PM
Edited Jun 26, 2011 at 3:51 PM

Hi!

Thanks you for your fast answer! I've done as you said, but I still have some issues. I've found some examples on the discussions, and pasted some lines. This is my initialization code: 

 

Public Class Form1

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' set cache mode only if no internet avaible
        Try
            Dim es As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry("www.google.com")
        Catch
            MainMap.Manager.Mode = AccessMode.CacheOnly
            MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET - Demo.WindowsForms", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End Try

        ' config map
        MainMap.MapType = MapType.GoogleMap

        MainMap.MaxZoom = 11
        MainMap.MinZoom = 1
        MainMap.Zoom = MainMap.MinZoom + 1
        MainMap.Position = New PointLatLng(54.6961334816182, 25.2985095977783) 'it's seems that currentposition can't be used anymore.

    End Sub

The problem I have is I get, at runtime, "tiles" with 2 messages; one with a red label indicating an exception with "singletoncreator" and another, blue, saying there is no images for that zoom level. (I don't transcribe them because they are in spanish).

 

Another question.... I've followed your discussion with Josh; can google maps still be used? I get the obsolete warning on the GoogleMap type.

 

Regards!

Coordinator
Jun 26, 2011 at 4:51 PM

did you set target to AnyCPU? And you can ignore warnings ;}

Jun 26, 2011 at 5:34 PM

Hi!

Yes, target is set to anycpu... but the problem still happens. And i'll ignore the warnings if you do so too :P

 

 

Coordinator
Jun 26, 2011 at 5:47 PM

..well try move out code from load event to form constructor

Jun 26, 2011 at 6:18 PM

Hi,

 

no luck; i've moved the code to a new form's initializecomponent event. I have a form, a gmapcontrol, and this code:

 

 Private Sub InitializeComponent()
        Me.GMapControl1 = New GMap.NET.WindowsForms.GMapControl()
        Me.SuspendLayout()
        '
        'GMapControl1
        '
        Me.GMapControl1.Bearing = 0.0!
        Me.GMapControl1.CanDragMap = True
        Me.GMapControl1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GMapControl1.GrayScaleMode = False
        Me.GMapControl1.LevelsKeepInMemmory = 5
        Me.GMapControl1.Location = New System.Drawing.Point(0, 0)
        Me.GMapControl1.MarkersEnabled = True
        Me.GMapControl1.MaxZoom = 17
        Me.GMapControl1.MinZoom = 2
        Me.GMapControl1.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter
        Me.GMapControl1.Name = "GMapControl1"
        Me.GMapControl1.NegativeMode = False
        Me.GMapControl1.PolygonsEnabled = True
        Me.GMapControl1.RetryLoadTile = 0
        Me.GMapControl1.RoutesEnabled = True
        Me.GMapControl1.ShowTileGridLines = False
        Me.GMapControl1.Size = New System.Drawing.Size(284, 262)
        Me.GMapControl1.TabIndex = 0
        Me.GMapControl1.Zoom = 0.0R
        Me.GMapControl1.MapType = MapType.GoogleMap

        Me.GMapControl1.MaxZoom = 11
        Me.GMapControl1.MinZoom = 1
        Me.GMapControl1.Zoom = GMapControl1.MinZoom + 1
        Me.GMapControl1.Position = New PointLatLng(54.6961334816182, 25.2985095977783)
        '
        'Form3
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(284, 262)
        Me.Controls.Add(Me.GMapControl1)
        Me.Name = "Form3"
        Me.Text = "Form3"
        Me.ResumeLayout(False)

    End Sub

 

I've added my own code after the auto-generated code. I also tried removing the "duplicate" assignments (min, max, zoom, type) and the same happens (error tiles indicating singletoncreator exception)

Coordinator
Jun 26, 2011 at 8:01 PM

do you use .net4?

Jun 26, 2011 at 8:13 PM

I had 4 client profile, switched to 4, same issue. visual studio 2010.

Coordinator
Jun 26, 2011 at 10:06 PM

did you tried to browse documentation page? ;}

Jun 27, 2011 at 12:59 AM

Hi!

Missed the useLegacyV2RuntimeActivationPolicy="true" line at app.config. I've read it but, for some reason, I thought it was for the web.config. "GMap.NET.WindowsForms" was kinda an empty section. Your reprimand :P about reading the documentation told me that there was more than meets the eye.


Thank you very much! See you soon.

Coordinator
Jun 27, 2011 at 6:39 AM

welcome ;}

p.s. in the next version you won't need any configs

Jun 27, 2011 at 2:33 PM

nice! and there is/there will be a way to use it on x86 builds? I'd like to edit code while debugging too much....

Coordinator
Jun 27, 2011 at 2:42 PM

yes, any target you want

Jun 27, 2011 at 2:50 PM

hi! 

the problem is that if I change the build to x86, i get the singletoncreator tiles...

Coordinator
Jun 27, 2011 at 2:57 PM

add manually sqlite dll, and disable assembly resolving in GMaps.cs static constructor

Jun 29, 2011 at 10:55 PM

Hi!

sqlite dll added, but i'm lost in your second indication... i don't even have a gmaps.cs class. could you give me some guide?

Regards!

 

Coordinator
Jun 30, 2011 at 7:29 AM

just build from source

Jul 2, 2011 at 4:16 AM

Hi!

It's seems I finally can workaroun this, and I'll share the solution.

Added the source code to my solution and added the references to gmap.net.core and gmap.net.windowsforms libraries. 


First of all, I've located the gmap.cs constructor and commented the assembly resolving:

 

static GMaps()
      {
         //AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
      }

 

Second, the source code component doesn't have the "mapttype" property? I've switched this:

'Me.Map.MapType = GMap.NET.MapType.GoogleMap
 Me.Map.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance

 

I have the sqlite reference in my project and in the core project, however, I got a sqlite library exception. I've noticed they where different versions, I've removed them and added the 1.0.66.0 on both. Also, I've manually switched all the projects to x86 builds.

 

QWell, I got the debuggin'edit on my project. Thank you very much for your help! see you soon.

 

 

 

 

 

Coordinator
Jul 2, 2011 at 6:57 AM

nice ;}

Coordinator
Sep 5, 2011 at 5:33 PM

current version in source requires no configs, and run on .net2/4 - x86/x64