Are there any wxWidgets based application/widiget to show maps and GPS tracks

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by ollydbg23 »

Hi, I have a USB GPS receiver, which I can receive the GPS information from the "virtual serial port".

Now, I would like to show the GPS position in a map(such as a street in the city), when searching on the internet, I see there is a page: https://wiki.openstreetmap.org/wiki/Software/Desktop

Which contains a lot of applications, but a lot of the applications are out-dated.

One similar application is: OpenCPN/OpenCPN: A concise ChartPlotter/Navigator. https://github.com/OpenCPN/OpenCPN, but this is generally for sea navigations, so my question is there is any one library/application which

1, can show GPS tracks in wxWidgets
2, can show a local(offline) maps

Thanks.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by doublemax »

As we finally have a proper wxWebView on all platforms (since the arrival of wxWEBVIEW_BACKEND_EDGE for Windows), i'd try to find a browser based solution.
Use the source, Luke!
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by ollydbg23 »

doublemax wrote: Tue Apr 27, 2021 5:19 am As we finally have a proper wxWebView on all platforms (since the arrival of wxWEBVIEW_BACKEND_EDGE for Windows), i'd try to find a browser based solution.
Hi, thanks for the reply.

I just search the internet, there are not much pages or tutorials about using wxWebView, for me, I don't have much experience about javascript and the web/html programming, so is it hard for me to do that? I think I need some start up resources.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by evstevemd »

Hi,
ollydbg23 wrote: Thu Apr 29, 2021 6:30 am
doublemax wrote: Tue Apr 27, 2021 5:19 am As we finally have a proper wxWebView on all platforms (since the arrival of wxWEBVIEW_BACKEND_EDGE for Windows), i'd try to find a browser based solution.
Hi, thanks for the reply.

I just search the internet, there are not much pages or tutorials about using wxWebView, for me, I don't have much experience about javascript and the web/html programming, so is it hard for me to do that? I think I need some start up resources.
What do you want to do with the co-ordinates exactly? That will help us propose anything we can.
If all you want to do is load coordinates on OSM you can do

Code: Select all

wxString lat = "-6.1744";
wxString lng = "35.7475";
wxString zoom = "16"; //Street view, adjust to your taste

wxString url = wxString::Format("https://www.openstreetmap.org/search?whereami=1&query=%s,%s#map=%s/%s/%", lat, lng, zoom, lat, lng);
wxWebView* browser = = wxWebView::New();
browser-> LoadURL(url);
For more on wxWebview, take a look at the sample
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by ollydbg23 »

evstevemd wrote: Thu Apr 29, 2021 8:37 am What do you want to do with the co-ordinates exactly? That will help us propose anything we can.
Hi, many thanks.
I want to draw the path of the GPS receiver on the osm map.
The co-ordinates are the locations of the GPS receiver.
The path could be drawn as a poly line on the map.

If all you want to do is load coordinates on OSM you can do

Code: Select all

wxString lat = "-6.1744";
wxString lng = "35.7475";
wxString zoom = "16"; //Street view, adjust to your taste

wxString url = wxString::Format("https://www.openstreetmap.org/search?whereami=1&query=%s,%s#map=%s/%s/%", lat, lng, zoom, lat, lng);
wxWebView* browser = = wxWebView::New();
browser-> LoadURL(url);
For more on wxWebview, take a look at the sample
I will try it. Thanks.
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by ollydbg23 »

Here is my test:

I'm using msys2, and I use the wx library prebuild in msys2, and it is wx 3.0.5.

I see that the webview's backend is IE.

Any way, I can create the https://github.com/wxWidgets/wxWidgets/ ... es/webview

And the application can run correctly, and I can open the https://www.openstreetmap.org/

So, the only thing I need is to call some web API(maybe javascript API), and I can add the points/track in the map. The track is dynamic, I mean I will add more points when the GPS receiver moves.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by PB »

The IE-based wxWebView backend is seriously outdated.

wxWidgets 3.1.5 offers the new Edge-based one (where new MS Edge is based on Chromium).

If you are stuck with wxWidgets 3.0, at least make sure you set the emulation level to the maximum, see e.g. here viewtopic.php?f=20&t=44405&p=182852#p182852
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by doublemax »

ollydbg23 wrote: Thu Apr 29, 2021 10:36 am So, the only thing I need is to call some web API(maybe javascript API), and I can add the points/track in the map. The track is dynamic, I mean I will add more points when the GPS receiver moves.
You can communicate with the webpage using wxWebView::RunScript
https://docs.wxwidgets.org/trunk/classw ... 0d463ffb98

Search the "webview" sample (of a current wxWidgets version) for occurences of "RunScript".

And, like PB said, you definitely want the ChromiumEdge backend. I doubt any modern web component will be compatible or fully functional under IE.
Use the source, Luke!
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by ollydbg23 »

PB wrote: Thu Apr 29, 2021 11:09 am The IE-based wxWebView backend is seriously outdated.

wxWidgets 3.1.5 offers the new Edge-based one (where new MS Edge is based on Chromium).

If you are stuck with wxWidgets 3.0, at least make sure you set the emulation level to the maximum, see e.g. here viewtopic.php?f=20&t=44405&p=182852#p182852
Hi, PB, thanks, I don't have MS Edge in my Windows 7 system, I use Firefox :D
I will try your code soon.
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by ollydbg23 »

doublemax wrote: Thu Apr 29, 2021 11:47 am
ollydbg23 wrote: Thu Apr 29, 2021 10:36 am So, the only thing I need is to call some web API(maybe javascript API), and I can add the points/track in the map. The track is dynamic, I mean I will add more points when the GPS receiver moves.
You can communicate with the webpage using wxWebView::RunScript
https://docs.wxwidgets.org/trunk/classw ... 0d463ffb98

Search the "webview" sample (of a current wxWidgets version) for occurences of "RunScript".

And, like PB said, you definitely want the ChromiumEdge backend. I doubt any modern web component will be compatible or fully functional under IE.
I understand this, thanks, I will first try IE based, because it looks like https://www.openstreetmap.org/ showns correctly in the webview page. I'm not sure if has some script to allow me to add customized paths.
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by ollydbg23 »

Some information about the C++ code to show the osm map file, I have take some time to tweak this project: https://github.com/Paulxia/osmbrowser

Though this project is 10 years old, but it is wx and cairo and expat library. Those libraries can be easily installed by the msys2's pacman command.

I'd tweak some code, and finally it works, see the screen shot in attachment. (I will supply the patches to my own github forks)
osmbrowser.png
When the mouse hovers near a "Node" in the osm map, it will show the information of that node in the right panel. :D
But I'm still not quite sure how to add tracks in its canvas, so still need some time to understand its code.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by ONEEYEMAN »

Hi,
Probably with wxOverlay?

Thank you.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Are there any wxWidgets based application/widiget to show maps and GPS tracks

Post by evstevemd »

ollydbg23 wrote: Thu Apr 29, 2021 10:17 am Hi, many thanks.
I want to draw the path of the GPS receiver on the osm map.
The co-ordinates are the locations of the GPS receiver.
The path could be drawn as a poly line on the map.
That require JS Library. There is openlayers and leaflet. Choose one and try playing around with WebView RunScript.
Here is a question on how to do that in Leaflet.
HTH
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Post Reply