none
how do i incorporate bing maps into vb.net program ? RRS feed

  • Question


  • hi 

    <g class="gr_ gr_15 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="15" id="15">i</g> wrote a desktop app using vb.net-2008.

    <g class="gr_ gr_23 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="23" id="23">i</g> want the user of my app to be able to enter an address and then see that location on a map .. <g class="gr_ gr_24 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="24" id="24">i</g> will convert the address to a lat-long coordinate.

    the program used to use google maps which no longer works.
    error message .. You seem to be using an unsupported browser.
    several forums have said this problem will never be fixed.

    ? can you tell me where <g class="gr_ gr_25 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="25" id="25">i</g> can find instructions on how to incorporate (bing) maps into my vb.net program .. sample code, etc.

    jerry .. wa0h .. jerrywa0h@sbcglobal.net
    Tuesday, March 6, 2018 8:21 PM

All replies

  • You will need an api key:

    https://www.microsoft.com/en-us/maps/create-a-bing-maps-key

    Then here is an example of how to use it to get a map:

    'bing maps api example Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load DoubleBuffered = True BackgroundImageLayout = ImageLayout.None Dim BingMapsKey As String = "enter your api key here" 'point with labels 'Dim url As String = "http://dev.virtualearth.net/REST/v1/Imagery/Map/AerialWithLabels/35.1377868652344,-106.642822265625/8?mapSize=1000,1000&key=BingMapsKey" 'rect Dim url As String = "http://dev.virtualearth.net/REST/v1/Imagery/Map/AerialWithLabels?mapArea=35,-108,37,-106&mapSize=600,600&key=" & BingMapsKey Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(url) Using request As System.Net.WebResponse = req.GetResponse Using stream As System.IO.Stream = request.GetResponseStream Dim bmp As Bitmap bmp = New Bitmap(System.Drawing.Image.FromStream(stream)) BackgroundImage = CType(bmp.Clone, Bitmap) bmp.Dispose() End Using End Using End Sub End Class






    Tuesday, March 6, 2018 10:36 PM
  • <g class="gr_ gr_9 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="9" id="9">i</g> have a key

    using latitude-longitude, how do <g class="gr_ gr_94 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="94" id="94">i</g> display a bing map in a (<g class="gr_ gr_118 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del multiReplace" data-gr-id="118" id="118">picturebox</g><g class="gr_ gr_234 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="234" id="234">) ?</g>

    jerry .. wa0h .. jerrywa0h@sbcglobal.net

    Friday, March 9, 2018 4:23 PM
  •  I think what you are asking is how to put your Latitude and Longitude into the url string so it will show the location you want.  If that is what you are asking,  below is a simple explanation of the parts in the url string.

            Dim url As String = "http://dev.virtualearth.net/REST/v1/Imagery/Map/AerialWithLabels/35.1377868652344,-106.642822265625/8?mapSize=1000,1000&key=BingMapsKey"
    
            '35.1377868652344  -> is the Latitude which can be (-90.000000 and 90.000000)
            '-106.642822265625 -> is the Longitude which can be (-180.000000 and 180.000000)
            '8                 -> is the zoom value which can be 1 to 19. 1 being further away from the ground and 19 being closer to the ground.
            '1000,1000         -> is the width,height of the map image you want returned.
    

     As I said in your other question,  all you need to do is change Tom's code a little to set the image to the PictureBox.Image property instead of setting it to the BackgroundImage property of the Form as Tom has shown.  You can also look at the code I posted in your other question which sets the Image to a PictureBox.

     Also,  please do not forget to mark the post or posts that answer your question(s) as the answers,  if they have answered your question(s).  Thanks.  8)


    If you say it can`t be done then i`ll try it

    Saturday, March 10, 2018 9:40 PM
  • Hi Tommy,

    I tried your code in VB.net and it functions good.
    My question is:
    You have written into the url-string latitude and longitude of a location.
    My interest is to write there an address of a location (country, city, zip, street...).
    How can I do that?

    Regards-


    Dietrich

    Tuesday, January 29, 2019 8:09 AM
  • Hi Tommy,

    I tried your code in VB.net and it functions good.
    My question is:
    You have written into the url-string latitude and longitude of a location.
    My interest is to write there an address of a location (country, city, zip, street...).
    How can I do that?

    Regards-


    Dietrich

    You can do a query by keywords etc. I have not tried it.

       https://docs.microsoft.com/en-us/bingmaps/rest-services/locations/find-a-location-by-query

    There are other ways in the topic tree at the left of the page.

    Tuesday, January 29, 2019 10:23 AM
  • Hi Tommy,

    Thankd for your tipp!
    Meanwhile I have done it. But there are some difficulties with zoom when I change the address...

    Otherwise I have another alternative with BingMaps:

    Dim url As String = "http://www.bing.com/maps/?lvl=6&where1=" & adr
    WebBrowser1.Navigate(url) 'display page in form
    

    with adr as an address of a location.
    This method shows the complete BingMap (menue and other controls include). I sought for a description of parameters of the url to make these controls unvisible. But I found no description!
    If everyone knows where to find a description to handle the view of BingMaps, please let me know!!

    Regards-


    Dietrich

    Wednesday, January 30, 2019 9:11 AM