#I'm building a 24/7 weather radar application in C++/Qt using QWebEngineView.

10 messages · Page 1 of 1 (latest)

marsh lark
#

I load a third-party weather website that uses Mapbox. The map loads and displays correctly, but when I inject JavaScript, I can't find the actual Mapbox map object. My code returns a "no-map" result even though the map is visible on screen.

calm chasmBOT
#

<@&987246683568103514> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
I load a third-party weather website that uses Mapbox. The map loads and displays correctly, but when I inject JavaScript, I can't find the actual Mapbox map object. My code returns a "no-map" result even though the map is visible on screen.

Your issue likely stems from the timing of your JavaScript injection. The Mapbox map object is created asynchronously by the third-party website, so when you run your script, the map object might not have been initialized yet. Since this is in a QWebEngineView context, make sure you execute your JS after the page’s load and fully populated DOM, or poll for the object’s existence.

Additionally, the map object is often scoped privately and not exposed globally, so calling it directly may fail. You might need to inspect the page's scripts to find how the map is stored (e.g., inside closures or variables bound to certain names).

Tips based on the old code approach:

  • Use QWebEnginePage::runJavaScript() inside a signal like loadFinished(bool) or a delay after that.
  • Instead of direct access, inject JS that repeatedly checks for the map object (e.g., via setInterval) and only returns when found or times out.
  • Verify the actual variable or property name the site uses via browser devtools before querying it in your injected script.

Useful links:

night swift
#

Why use c++?

#

what do you gain if you now have to get html pages

#

and display it

indigo jungle
#

Shirley, there is some other forum better suited for this question. Like the api docs of the "third party web site". Are they supplying the data or the widget or both?

marsh lark
#

They aren’t supplying the weather data. My app already retrieves and processes alert data. I started the project in C++, which is why it’s still in C++. I now mainly use the website for radar/map visualization. My app displays alerts, manages prioritization, TTS, rotation, and weather logic. The website only serves as a map layer, not as the alert data source.

indigo jungle
#

I looked at mapbox website, it's expensive and the free tier doesn't seem to provide much so if you're abusing someone elses mapbox acct for your purposes then I suspect that is the problem.

random yarrow
#

I have the feeling a guy with a rainy cloud in his pfp would pay an expensive price for a map to put weather infos on it.