locked
Map control in vb.net RRS feed

  • Question

  • Hey :) 

    is there any control that show a map in a form and allow me to locate any place just by its coordinates

    i found a googlemaps control but internet is required , i want something that i can use without internet

    srry for my bad english :p

    Saturday, October 15, 2011 11:54 PM

Answers

  • Sure, let's see if this helps. I have two textboxes, one button and one webbrowser. The names should be apparent:

     


    CODE

        Private latitude As Double = 0
        Private longitude As Double = 0
    
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            btn_ShowMap.Enabled = False
    
    
        End Sub
    
    
    
        Private Sub TextBoxes_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles tb_Latitude.TextChanged, tb_Longitude.TextChanged
    
            If tb_Latitude.Text.Trim <> "" AndAlso tb_Longitude.Text.Trim <> "" Then
                btn_ShowMap.Enabled = True
            Else
                btn_ShowMap.Enabled = False
            End If
    
        End Sub
    
    
    
        Private Sub tb_Latitude_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_Latitude.Leave
    
            If Not Double.TryParse(tb_Latitude.Text, latitude) Then
                MessageBox.Show("The entry for latitude is invalid. Please re-enter", _
                                "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    
                With tb_Latitude
                    .SelectAll()
                    .Focus()
                End With
    
                btn_ShowMap.Enabled = False
            End If
    
        End Sub
    
    
    
        Private Sub tb_Longitude_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_Longitude.Leave
    
            If Not Double.TryParse(tb_Longitude.Text, longitude) Then
                MessageBox.Show("The entry for longitude is invalid. Please re-enter", _
                                "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    
                With tb_Longitude
                    .SelectAll()
                    .Focus()
                End With
    
                btn_ShowMap.Enabled = False
            End If
    
        End Sub
    
    
    
        Private Sub btn_ShowMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ShowMap.Click
    
            Dim googleQuery As String = _
            "http://maps.google.com/maps?q=" & latitude.ToString & "%2C" & longitude.ToString
    
            Try
                WebBrowser1.Navigate(googleQuery)
    
            Catch ex As Exception
                MessageBox.Show("An error occured:" & vbCrLf & vbCrLf & ex.Message, _
                                "Program Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
    
        End Sub
    


    I hope it helps. :)

    • Marked as answer by Mike Feng Monday, October 17, 2011 11:17 AM
    Sunday, October 16, 2011 4:48 PM
  • Hi SAID:

    I recommend that you look at the Dot Spacial project on codeplex: http://dotspatial.codeplex.com/

    I just found this and it took me about 5 minute of reading the tutorial to get a working map function.  The only drawback is that the tutorial examples are in C#, but this is a .Net 4.0 control set that can be integrated in the  VB2010 Express toolbox very easily.

    The thing that you need to get is the shape files that generate the map.  Luckily there are a lot of free shape files available for download.  The most common format appear to be "ARCGIS shapefile" from ESRI the Framily Tree Mike mentioned.  Just use your favorite search engine and search for "ARCGIS shapefile".

    This site, http://www.mapcruzin.com/download-free-arcgis-shapefiles.htm, has a lot of good links to free data.

    Have fun!

     

     

    • Proposed as answer by Frank L. Smith Monday, October 17, 2011 12:03 AM
    • Marked as answer by Mike Feng Monday, October 17, 2011 11:18 AM
    Sunday, October 16, 2011 10:51 PM

All replies

  • We use a commercial product from http://www.esri.com.  Their tools are very good, but can be expesive.

    --
    Mike
    Sunday, October 16, 2011 1:12 AM
  • We use a commercial product from http://www.esri.com.  Their tools are very good, but can be expesive.

    --
    Mike

    heY

    Im looking for something free and no internet connection needed , but ty for yur help :)


    Hey :)
    Sunday, October 16, 2011 9:48 AM
  • We use a commercial product from http://www.esri.com.  Their tools are very good, but can be expesive.

    --
    Mike

    heY

    Im looking for something free and no internet connection needed , but ty for yur help :)


    Hey :)


    The "no internet" part will be a real stumbling block. If you'll reconsider that part, then there may be a solution.

    If you're willing to reconsider that part, then tell me how are you going to give it what to show? Will the user be entering, for instance, latitude and longitude or ... just how?

    Sunday, October 16, 2011 3:44 PM
  • We use a commercial product from http://www.esri.com.  Their tools are very good, but can be expesive.

    --
    Mike

    heY

    Im looking for something free and no internet connection needed , but ty for yur help :)


    Hey :)


    The "no internet" part will be a real stumbling block. If you'll reconsider that part, then there may be a solution.

    If you're willing to reconsider that part, then tell me how are you going to give it what to show? Will the user be entering, for instance, latitude and longitude or ... just how?

    Yes , the user is going to input latitude and longitude , then a small triangle will show him the place
    Hey :)
    Sunday, October 16, 2011 3:56 PM
  • Yes , the user is going to input latitude and longitude , then a small triangle will show him the place
    Will they have an internet connection? That's still an issue if not.
    Sunday, October 16, 2011 3:58 PM

  • Will they have an internet connection? That's still an issue if not.

    No :( , without internet connection

    i have an idea but i don't know how to do it , i want to put a map in a form and determinate the point 0 and the scale

    i don't know if it this is possible


    Hey :)
    Sunday, October 16, 2011 4:08 PM
  • Well that kills my idea then - I was going to suggest using Google Maps.

    If you're interested to see what I'd done with it, click here (the image is too large to post directly). It's my location that you'll see as the latitude and longitude.

    Sunday, October 16, 2011 4:31 PM
  • Well that kills my idea then - I was going to suggest using Google Maps.

    If you're interested to see what I'd done with it, click here (the image is too large to post directly). It's my location that you'll see as the latitude and longitude.

    Thats Coool , would u send me the source code plzz , i think Google Maps is better :)

     


    Hey :)
    Sunday, October 16, 2011 4:38 PM
  • Sure, let's see if this helps. I have two textboxes, one button and one webbrowser. The names should be apparent:

     


    CODE

        Private latitude As Double = 0
        Private longitude As Double = 0
    
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            btn_ShowMap.Enabled = False
    
    
        End Sub
    
    
    
        Private Sub TextBoxes_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles tb_Latitude.TextChanged, tb_Longitude.TextChanged
    
            If tb_Latitude.Text.Trim <> "" AndAlso tb_Longitude.Text.Trim <> "" Then
                btn_ShowMap.Enabled = True
            Else
                btn_ShowMap.Enabled = False
            End If
    
        End Sub
    
    
    
        Private Sub tb_Latitude_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_Latitude.Leave
    
            If Not Double.TryParse(tb_Latitude.Text, latitude) Then
                MessageBox.Show("The entry for latitude is invalid. Please re-enter", _
                                "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    
                With tb_Latitude
                    .SelectAll()
                    .Focus()
                End With
    
                btn_ShowMap.Enabled = False
            End If
    
        End Sub
    
    
    
        Private Sub tb_Longitude_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_Longitude.Leave
    
            If Not Double.TryParse(tb_Longitude.Text, longitude) Then
                MessageBox.Show("The entry for longitude is invalid. Please re-enter", _
                                "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    
                With tb_Longitude
                    .SelectAll()
                    .Focus()
                End With
    
                btn_ShowMap.Enabled = False
            End If
    
        End Sub
    
    
    
        Private Sub btn_ShowMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ShowMap.Click
    
            Dim googleQuery As String = _
            "http://maps.google.com/maps?q=" & latitude.ToString & "%2C" & longitude.ToString
    
            Try
                WebBrowser1.Navigate(googleQuery)
    
            Catch ex As Exception
                MessageBox.Show("An error occured:" & vbCrLf & vbCrLf & ex.Message, _
                                "Program Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
    
        End Sub
    


    I hope it helps. :)

    • Marked as answer by Mike Feng Monday, October 17, 2011 11:17 AM
    Sunday, October 16, 2011 4:48 PM
  • Thank you so much my friend :) :)

    its really what i need 


    Hey :)
    Sunday, October 16, 2011 4:51 PM
  • Thank you so much my friend :) :)

    its really what i need 


    Hey :)


    Glad it helped.

    :)

    Sunday, October 16, 2011 4:53 PM
  • If you can get a map image of (for example) Africa, that shows the equator as well as cities/towns or landmarks, you can then use google to find the Lat./Lon. of one of the cities on your map, say Nairobi, which is ~1 deg S of the equator. If on your image Nairobi is 5 pixels from the equator, then you know 5 pixels = 1 Deg. (do the same for East/West).

    Now when your user enters a location, say Lat. 5 0 N... all  you have to do is multiply 5*5 (in my example), and mark on the map 25 pixels north of the equator.

    MP

    Sunday, October 16, 2011 4:58 PM
  • Hi SAID:

    I recommend that you look at the Dot Spacial project on codeplex: http://dotspatial.codeplex.com/

    I just found this and it took me about 5 minute of reading the tutorial to get a working map function.  The only drawback is that the tutorial examples are in C#, but this is a .Net 4.0 control set that can be integrated in the  VB2010 Express toolbox very easily.

    The thing that you need to get is the shape files that generate the map.  Luckily there are a lot of free shape files available for download.  The most common format appear to be "ARCGIS shapefile" from ESRI the Framily Tree Mike mentioned.  Just use your favorite search engine and search for "ARCGIS shapefile".

    This site, http://www.mapcruzin.com/download-free-arcgis-shapefiles.htm, has a lot of good links to free data.

    Have fun!

     

     

    • Proposed as answer by Frank L. Smith Monday, October 17, 2011 12:03 AM
    • Marked as answer by Mike Feng Monday, October 17, 2011 11:18 AM
    Sunday, October 16, 2011 10:51 PM
  • Hi SAID:

    I recommend that you look at the Dot Spacial project on codeplex: http://dotspatial.codeplex.com/

    I just found this and it took me about 5 minute of reading the tutorial to get a working map function.  The only drawback is that the tutorial examples are in C#, but this is a .Net 4.0 control set that can be integrated in the  VB2010 Express toolbox very easily.

    The thing that you need to get is the shape files that generate the map.  Luckily there are a lot of free shape files available for download.  The most common format appear to be "ARCGIS shapefile" from ESRI the Framily Tree Mike mentioned.  Just use your favorite search engine and search for "ARCGIS shapefile".

    This site, http://www.mapcruzin.com/download-free-arcgis-shapefiles.htm, has a lot of good links to free data.

    Have fun!

     

     

    Hey , thank you so much my friend

    im gonna read about the tutorial i hope its easy to use :p

    i think its the best solution , better than googleMaps :)

    thank you again my friend

     


    Hey :)
    Sunday, October 16, 2011 11:05 PM
  • If you go with shapefiles, the format can be found here: http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
     
    --
    Mike
    Sunday, October 16, 2011 11:31 PM
  • Hi SAID:

    I recommend that you look at the Dot Spacial project on codeplex: http://dotspatial.codeplex.com/

    I just found this and it took me about 5 minute of reading the tutorial to get a working map function.  The only drawback is that the tutorial examples are in C#, but this is a .Net 4.0 control set that can be integrated in the  VB2010 Express toolbox very easily.

    The thing that you need to get is the shape files that generate the map.  Luckily there are a lot of free shape files available for download.  The most common format appear to be "ARCGIS shapefile" from ESRI the Framily Tree Mike mentioned.  Just use your favorite search engine and search for "ARCGIS shapefile".

    This site, http://www.mapcruzin.com/download-free-arcgis-shapefiles.htm, has a lot of good links to free data.

    Have fun!

     

     


    Wow ... that looks like a great solution!
    Monday, October 17, 2011 12:03 AM
  • If you are not using an internet connection, then what maps are you going to use?

    There are many maps of different sorts available - both free and commercial.   For instance, the complete marine chart catalog for the United States is available for free download.  Complete maps of the UK are available for download for a fee.  Private organisaations package satellite imagery in map format.   The map that you intend to use will determine how you will display it and how you will identify positions on that map.  Some maps are graphical images with a set of reference data (inforrmation about the coordinates of the map) either embedded or as a separate file.   Some maps are provided in database format and the image is costructed from the data in the database.  These are particularly good for finding locations by name, as each element of the map has a position as part of its data.

    It all depends on the maps you intend to use.

    Monday, October 17, 2011 12:18 AM