Hi guys,
I need to create small desktop application which will show the users some direction between two points on map. User need to input first adress and second adress and I will show him the road from start to end point.
I found API for this on OpenRoute or OpenStreet Map (okey, basicaly I can use google maps but is not free)... In any case - I can get info from Api with next code:
I recived this response - In Json:
And what now?
How can I use result to show user the location (or direction)?! It's posible to show map inside of desktop B4J app with WebView?
And how?
I can not find any example... Sorry, maybe it's stupid question, I'm new in world of B4J with web api... Any suggestion how to move forward will more as usefull...
Tnx, Darko
I need to create small desktop application which will show the users some direction between two points on map. User need to input first adress and second adress and I will show him the road from start to end point.
I found API for this on OpenRoute or OpenStreet Map (okey, basicaly I can use google maps but is not free)... In any case - I can get info from Api with next code:
Api:
Dim Link As String = "https://api.openrouteservice.org/geocode/search?api_key=5b3ce3597851110001cf6248c9fa82847ccd4fc39a876be87bc92830&text=wien&boundary.country=AT&sources=openstreetmap"
Dim j As HttpJob
j.Initialize("j", Me)
j.poststring(Link, "")
j.GetRequest.SetHeader("Accept", "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8")
wait for (j) jobdone (j As HttpJob)
' if is sucess
If j.Success Then
Log(j.GetString)
Else
Log(j.ErrorMessage)
End If
j.Release
I recived this response - In Json:
Json response:
{"geocoding":{"version":"0.2","attribution":"https://openrouteservice.org/terms-of-service/#attribution-geocode","query":{"text":"wien","size":10,"sources":["openstreetmap"],"layers":["venue","street"],"private":false,"boundary.country":["AUT"],"lang":{"name":"English","iso6391":"en","iso6393":"eng","via":"default","defaulted":true},"querySize":20,"parser":"pelias","parsed_text":{"subject":"wien","locality":"wien"}},"warnings":["performance optimization: excluding 'address' layer"],"engine":{"name":"Pelias","author":"Mapzen","version":"1.0"},"timestamp":1637692353179},"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[16.336282,48.196545]},"properties":{"id":"node/60093107","gid":"openstreetmap:venue:node/60093107","layer":"venue","source":"openstreetmap","source_id":"node/60093107","name":"Wien Westbahnhof","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Westbahnhof","neighbourhood_gid":"whosonfirst:neighbourhood:85898759","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Wien Westbahnhof, Vienna, Austria","addendum":{"osm":{"wheelchair":"yes","wikidata":"Q698145","wikipedia":"de:Wien Westbahnhof","operator":"ÖBB-Infrastruktur AG"}}}},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.377855,48.18501]},"properties":{"id":"node/1839787470","gid":"openstreetmap:venue:node/1839787470","layer":"venue","source":"openstreetmap","source_id":"node/1839787470","name":"Wien Hauptbahnhof","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Favoriten","neighbourhood_gid":"whosonfirst:neighbourhood:85898653","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Wien Hauptbahnhof, Vienna, Austria","addendum":{"osm":{"wheelchair":"yes","wikidata":"Q697300","wikipedia":"de:Wien Hauptbahnhof","operator":"ÖBB-Infrastruktur AG"}}}},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.367778,48.260228]},"properties":{"id":"node/3488369063","gid":"openstreetmap:venue:node/3488369063","layer":"venue","source":"openstreetmap","source_id":"node/3488369063","name":"Wien Nußdorf","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Nussdorf","neighbourhood_gid":"whosonfirst:neighbourhood:85898361","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Wien Nußdorf, Vienna, Austria","addendum":{"osm":{"wikidata":"Q18762414","wikipedia":"de:Bahnhof Wien Nußdorf","operator":"ÖBB-Infrastruktur AG"}}}},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.36089,48.213006]},"properties":{"id":"relation/1441683","gid":"openstreetmap:venue:relation/1441683","layer":"venue","source":"openstreetmap","source_id":"relation/1441683","name":"Universität Wien","housenumber":"1","street":"Universitätsring","postalcode":"1010","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Hofburg","neighbourhood_gid":"whosonfirst:neighbourhood:85898679","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Universität Wien, Vienna, Austria","addendum":{"osm":{"wikidata":"Q19971231","wikipedia":"de:Hauptgebäude der Universität Wien","website":"https://www.univie.ac.at/"}}},"bbox":[16.3590774,48.2123003,16.3612496,48.2139265]},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.350026,48.247491]},"properties":{"id":"way/385797837","gid":"openstreetmap:venue:way/385797837","layer":"venue","source":"openstreetmap","source_id":"way/385797837","name":"Karmelitenkonvent Wien","housenumber":"35","street":"Silbergasse","postalcode":"1190","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Dobling","neighbourhood_gid":"whosonfirst:neighbourhood:85904321","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Karmelitenkonvent Wien, Vienna, Austria","addendum":{"osm":{"wikidata":"Q1734055","wikipedia":"de:Karmelitenkloster Döbling","website":"http://wien.karmel.at/"}}},"bbox":[16.3495683,48.2471502,16.3503436,48.247675]},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.376653,48.194928]},"properties":{"id":"way/162606842","gid":"openstreetmap:venue:way/162606842","layer":"venue","source":"openstreetmap","source_id":"way/162606842","name":"AK Wien","housenumber":"20-22","street":"Prinz-Eugen-Straße","postalcode":"1040","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Belvedere","neighbourhood_gid":"whosonfirst:neighbourhood:85898645","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"AK Wien, Vienna, Austria","addendum":{"osm":{"wheelchair":"yes"}}},"bbox":[16.3755555,48.1944249,16.3768113,48.1954201]},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.385987,48.2078]},"properties":{"id":"node/253157427","gid":"openstreetmap:venue:node/253157427","layer":"venue","source":"openstreetmap","source_id":"node/253157427","name":"Handelsgericht Wien","housenumber":"1a","street":"Marxergasse","postalcode":"1030","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Landstraße","neighbourhood_gid":"whosonfirst:neighbourhood:85898697","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Handelsgericht Wien, Vienna, Austria","addendum":{"osm":{"wheelchair":"yes"}}}},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.35725,48.206842]},"properties":{"id":"node/3425352392","gid":"openstreetmap:venue:node/3425352392","layer":"venue","source":"openstreetmap","source_id":"node/3425352392","name":"Oberlandesgericht Wien","housenumber":"11","street":"Schmerlingplatz","postalcode":"1011","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Hofburg","neighbourhood_gid":"whosonfirst:neighbourhood:85898679","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Oberlandesgericht Wien, Vienna, Austria","addendum":{"osm":{"wheelchair":"yes"}}}},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.434439,48.213508]},"properties":{"id":"way/350584631","gid":"openstreetmap:venue:way/350584631","layer":"venue","source":"openstreetmap","source_id":"way/350584631","name":"Wakeboardlift Wien","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","neighbourhood":"Praterbrucke","neighbourhood_gid":"whosonfirst:neighbourhood:85898375","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Wakeboardlift Wien, Wien, WI, Austria","addendum":{"osm":{"operator":"Wakeboardlift Wien","website":"http://www.wakeboardlift.at/"}}},"bbox":[16.4324688,48.2121666,16.4363617,48.2148417]},{"type":"Feature","geometry":{"type":"Point","coordinates":[16.420271,48.270761]},"properties":{"id":"node/3313275952","gid":"openstreetmap:venue:node/3313275952","layer":"venue","source":"openstreetmap","source_id":"node/3313275952","name":"Wien Siemensstraße","confidence":1,"match_type":"exact","accuracy":"point","country":"Austria","country_gid":"whosonfirst:country:85632785","country_a":"AUT","region":"Vienna","region_gid":"whosonfirst:region:85681667","region_a":"WI","localadmin":"Wien","localadmin_gid":"whosonfirst:localadmin:1108838101","locality":"Vienna","locality_gid":"whosonfirst:locality:101748073","neighbourhood":"Neujedlersdorf","neighbourhood_gid":"whosonfirst:neighbourhood:85898343","continent":"Europe","continent_gid":"whosonfirst:continent:102191581","label":"Wien Siemensstraße, Vienna, Austria","addendum":{"osm":{"wheelchair":"yes","operator":"ÖBB-Infrastruktur AG"}}}}],"bbox":[16.336282,48.18501,16.4363617,48.270761]}
And what now?
How can I use result to show user the location (or direction)?! It's posible to show map inside of desktop B4J app with WebView?
And how?
I can not find any example... Sorry, maybe it's stupid question, I'm new in world of B4J with web api... Any suggestion how to move forward will more as usefull...
Tnx, Darko