Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inser map from url 2

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
428
IT
based:
Private Sub MAPPA()

'
'SEE THE LAST POST

Dim strurl As String
strurl = "
Shape1.Fill.UserPicture strurl

End Sub

i have insert a shape on form but have error:

metod or data member not found

.Fill

note:
i just have a shape1 on form
naturally other way are welcomed, also to use image1
 
You are in VB6 Forum, and VB6 does have a Shape control, but there is no Fill method for that control.
There are FillColor and FillStyle, but no Fill... :-(

Shape_wkoz3g.png


You may want to Download file from the Web first, and then display it on your form.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
ok
but possible to use a image1, instead?
 
Yes... But you need to have something first to show/display.

Code:
Image1.Picture = LoadPicture("C:\SomeFolder\APicture.jpg")

You may do the same with a PictureBox:

Code:
Picture1.Picture = LoadPicture("C:\SomeFolder\APicture.jpg")

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Erm ... why not just display it in the webbrowser control?

Or, as advised in thread222-1806900, why not use the Bing map v8 control that you bing key gives you access to - it should allow you to

"display few locations on a map
display a route between points on a map
get a distance/driving time between points
 
Hi strongm,
tkx.
i read the second suggestion...

but how to use the url in web browser control?
Example.
 
>how to use the url in web browser control?

Stick a browser control on your form, then

Code:
[blue]WebBrowser1.Navigate "[URL unfurl="true"]http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?wp.0=Seattle,WA;64;1&wp.1=Redmond,WA;66;2&key=<your[/URL] bing key>"[/blue]

P.S You might want to hide your key in these posts
 
In VB6: Project - Components... Select "Microsoft Internet Controls", click OK.
That will add a WebBrowser to your ToolBox

Code:
WebBrowser1.Navigate "[URL unfurl="true"]www.google.com"[/URL]


---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
TKS STRONGM AND ANDY!
But really this is not for me, very complex ...
I really want to show the route/diving Bing map in a form, in browser, in image..ecc
i know the latitude and longitude or have a zip code, from initial and finish destination, i just have a a Bing key.

the data eaxample is:

zip code
from Napoli 80100 to Roma 00100

coordinate
from Napoli lat 40,8522- long 14,2681 to Roma lat 41,8919 long 12,5113

this is what I have.
In other case, if is very complex for you, many many tks!
 
> very complex ... very complex ...

Which bit is complex? Putting a control on a form |(and if this IS hard for you then I take back my advice about using the Bing Maps control as it is substantially harder to use)? Navigating to a URL for that control? Figuring out the necessary query?

The Bing REST API (which is what you use to create the query)is fully documented and I have previously linked you to it in thread222-1803165). This is a VB forum, not a Bing REST API forum, so we're not likely to provide much advice to you on that, particularly when you can read the documentation

B ut, as a pointer, here's building the relevant REST API call to display the relevant 640x480px map for both the zipcosde and a long/lat

Andy has already explained how to make the webbrowser control available in the IDE's toolbox. You need, as I advised, to drop one of them (just like you dropped the shape control) onto your form. Size it to 640 by 480 pixels if you like

Add two command buttons, rename them as cmdZips and d cmdLongLat. Then copy and paste the following code into your form:

Code:
[blue]Private Sub cmdZips_Click()
    Dim wp0 As String
    Dim wp1 As String

    wp0 = "Naples,80100"
    wp1 = "Rome,00100"
    WebBrowser1.Navigate "[URL unfurl="true"]http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?wp.0="[/URL] & wp0 & "&wp.1=" & wp1 & "&mapsize=640,480&key=<your bing key>"
End Sub

Private Sub cmdLongLat_Click()
    Dim wp0 As String
    Dim wp1 As String

    wp0 = "40.8522,14.2681"
    wp1 = "41.8919,12.5113"
    WebBrowser1.Navigate "[URL unfurl="true"]http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?wp.0="[/URL] & wp0 & "&wp.1=" & wp1 & "&mapsize=640,480&key=<your bing key>"
End Sub
[/blue]

And the below is what all that massive amount of code produces, with start and end points and the route shown:

ttexample_u7aouu.png




Oh, and the reason that you got an error with .fill in your OP is that that is not something supported by VB's shape controls. It exists in some shape classes in some VBA hosts (e.g. Excel)
 
Wow!!!
Tks Bro!
But possibile not show the verticale an orizzontal dragbar, in webbroser control?
 
YUes it is possibkle - just add

Private Sub WebBrowser1_DownloadComplete()
WebBrowser1.Document.body.Scroll = "no"
End Sub
 
You need a separate query

As an example (and always remember I am only pointing you in the right direction - none of this is production level code), add the following to the form you should have created for previous example above. You'll also need to a reference to [tt]Microsoft XML[/tt]

Code:
[blue]Private Sub Details(wp0 As String, wp1 As String)
    Dim APICall As String
    Dim Query As String
    Dim strKey As String
    Dim myXML As New MSXML2.DOMDocument60
    Dim nodes As IXMLDOMSelection

    APICall = "[URL unfurl="true"]http://dev.virtualearth.net/REST/V1/Routes/Driving"[/URL]
    Query = "?output=xml&maxSolns=1&wp.0=" & wp0 & " &wp.1=" & wp1 & "&routeAttributes=excludeItinerary,routePath&optimize=time"
    strKey = "&key=<your bing key>"
    
    With CreateObject("MSXML2.XMLHTTP")
        .open "GET", APICall & Query & strKey, False
        .send
        myXML.loadXML .responseText 'raw xml
        Set nodes = myXML.selectNodes("//*")
        MsgBox "Time: " & TimeSerial(0, 0, GetFirstNamedNode("TravelDuration", nodes).Text) & vbCrLf & "Distance: " & GetFirstNamedNode("TravelDistance", nodes).Text & " km"   'km
    End With
End Sub

Private Function GetFirstNamedNode(myNode As String, myNodes As IXMLDOMSelection) As IXMLDOMElement
    Dim seeknode As IXMLDOMElement
    
    For Each seeknode In myNodes
        If seeknode.nodeName = myNode Then
            Set GetFirstNamedNode = seeknode
            Exit For
        End If
    Next
End Function[/blue]

Then m odify the existing code in that previous example as follows:

Code:
[blue]Private Sub cmdZips_Click()
    Dim wp0 As String
    Dim wp1 As String

    wp0 = "Naples,80100"
    wp1 = "Rome,00100"
    WebBrowser1.Navigate "[URL unfurl="true"]http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?wp.0="[/URL] & wp0 & "&wp.1=" & wp1 & "&mapsize=640,480&key=<your bing key>"
    [b][COLOR=red]Details wp0, wp1[/color][/b]
End Sub

Private Sub cmdLongLat_Click()
    Dim wp0 As String
    Dim wp1 As String

    wp0 = "40.8522,14.2681"
    wp1 = "41.8919,12.5113"
    WebBrowser1.Navigate "[URL unfurl="true"]http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?wp.0="[/URL] & wp0 & "&wp.1=" & wp1 & "&mapsize=640,480&key=<your bing key>"
    [b][COLOR=red]Details wp0, wp1[/color][/b]
End Sub[/blue]
 
Strongm you are a gentleman!

The code work like a charm!
Tks.


Note:
But instead to have a portion of map possible to have the entire map of Italy, naturally with the point A and point B ....
 
>But instead to have a portion of map possible to have the entire map of Italy

But of course - just read the documentation ... ;-)
 
Ok
But now have in my mind o a milioni of link....
Wath exactlly Is the link:
just read the documentation
 
Ho strong i have sera in any parte of document, but not foundd the TIPS ti show entire map of Italy.
Tks
 
Ok, so here's a clue as to how I'd do it. I'd firstly look at the various ways there might be to use the API to display a particular area of a map. And there is - [tt]mapArea[/tt] (documented under parameters on this page. So, now I'd know that I can display any bit of a map simply by defining a boundingbox. And the mapArea documentasti0on provides a link to precisely what a boundingbox is and how the API expects it to be expressed. Basically as long as you know the top left and bottom right coordinates of the area you want to display in terms of lat/long pairs you are good to go.

But you may not know. So is there anyway of getting Bing to give us a boundingbox of a know geographical area. The answer is yes (althpugh Bing's idea of a the bounding rectangle may differ a bit from our own - may often be a bit bigger to be on the safe side), and it is documented here, where we can see that [tt]BoundingBox[/tt] parameter means that Bing will return the boundingbox (surprise, surprise) of the location we request. So, if we were to query for a country, we'd get the bounding box for that country which (after parsing from JSON or XML), can then be fed as an additional parameter into our static map request
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top