Google Maps Draw Route malfunction in Windows - javascript

tldr: recently, my use of the Google Maps JavaScript API v3 does not show routes or markers anymore. It works fine on my Debian-box, but not on any Windows computer I tried (ranging XP to Windows 8). Has there been a recent change in the API? Is my code buggy? see http://pastebin.com/ubRGPtDZ
Dear All,
in August 2014, I wrote a Qt program that at some stage shows Google Maps in a QWebView . Through JavaScript I was able to draw a route.
This program has been functioning fine, up to mid-December. On my Linux-box (Debian), it still works fine, but on every Windows computer I try, stops showing the route. Google Maps itself shows fine, but it stops showing any route, any marker, ...
Did anything change in Google Maps mid-December 2014? I checked the changelog of Javascript Maps API v3 , but I do not see any new mention after September 2014.
Should I check somewhere else?
Or is there any change in QWebView-behaviour on Windows-boxes since mid December? Is that even possible?
I still hold possible that my JavaScript tweaking is inadequate, so I will debug that code as well, but definitely baffles me that everything worked fine for over 4 months on Windows-computers, and still does on my Debian-Box. I have put it online at http://pastebin.com/ubRGPtDZ .
My apologies for any bad English, non-native speaker here.
Thank you all for any suggestion.
Wim

Found it! This was a very frustrating challenge, but it feels great now that it is solved. It took me days of browsing through any documentation possible, of pure trial-and-error, testing and doubting every aspect of my code or even configuration, all failed... But one more time I browsed the qt-project and found this post by lowsnr and Yuvalal.
In the words of lowsnr:
as part of the test that the Google code performs to determine
whether the browser is touch enabled, it checks the User Agent for
Chrome >= 5.0, so by changing the user agent to something like
‘Chrome/1.0’ the touch interface suppressed.
Apparently it is also needed for displaying the directions (*). So I wrapped up a new class called myWebPage and derived it from qWebPage:
class myWebPage : public QWebPage
{
virtual QString userAgentForUrl(const QUrl& url) const {
return "Chrome/1.0";
}
};
and before loading the HTML in the qWebView, I use setPage():
ui->setupUi(this);
ui->webView->setPage(new myWebPage());
ui->webView->setHtml("...");
Now it works like a charm :-)
--
(*) For me, the prove that the problem was not my JavaScript, is that I tried to simply load the same HTML script as used in the Google Maps code examples. In a QWebView, it works fine for my Linux-box, but refuses to show the directions on any Windows-compiled binary that I tried. Still, the code works fine if you load to a regular browser.
Conclusion: Google Maps does not necessary like QWebView.

Related

JavaScript stops working for all Google Sheets and Docs

My Google Docs and Sheets were working fine yesterday. Today, the same file (no changes made) does not run my JavaScript. In fact, any new Doc/Sheet files I create will no longer run JavaScript. It appears that Google itself is blocking JavaScript on my Google account, but I am not sure. There is no error message, no log. I thought it was a device issue, because it started working again on my new devices but, eventually, all my devices have stopped working. Note: My devices have different operating systems, different browsers, but all eventually experience this issue. I tried reinstalling browsers, new Windows installs. Note: even simple JavaScript alert popups will no longer work from my Google files. General web browsing (outside of Google Workspace development) is running good. I am so confused!
I am going to close this question. I have discovered that google has intentionally removed alert and other javascript features - more information at this link: https://www.chromestatus.com/feature/5148698084376576
I will have to find another way to implement the javascript alert functionality. Thank-you all for any consideration you gave my question.

Get CPU Usage detail in browser [duplicate]

I noticed this today in my Chrome.
Google Meet is showing a chart of CPU usage in their "Troubleshooting" panel. I'm wondering if there's an existing API for this or is it a clever trick I'm not aware of.
I was curious about this as well when I saw the CPU Usage graph on the Troubleshooting page on the Google Meet's page. So googled a lot and I couldn't find any proper answer as to how it is being achieved apart from this link: https://developer.chrome.com/extensions/system_cpu#method-getInfo.
So, I went through the minified source code of the Google Meet's site and it turns out Google Meet is using this but not on their webpage directly, because it is for chrome extensions only, but through the Google Hangouts Extension which is present in Chrome, Brave and the new Microsoft Edge (Chromium-based).
The chrome extension is calling the chrome.system.cpu API to get the information about the processor, core count, temperatures, etc., and these details are being passed to the Google Meets page via window.postMessage API and Message Passing between Chrome Extension and a Webpage.
This is a neat little way to achieve this if you are the creator of the browser :P.
Most probably, they are using Chrome specific API since this will not work on other browsers.
The closest thing that I've found is https://developer.chrome.com/extensions/system_cpu#method-getInfo
Below is a screenshot from Firefox stating that this will work only on Chrome.

How Can I Spoof A Different Location In My Browser for Testing?

I couldn't find this in the linked questions above.
I have written a JS Web app that uses Google Maps. I'm getting reports from India that the browser location isn't being found on the mobile version of the app, and I need to be able to debug it (I live in New York).
It works fine in the NY installation, so I need to test on the Indian installation.
The problem is that I need my browser to report a local long/lat, so I can trigger that JS code path.
Is there a way to get my browser to spoof a long/lat?
This is the only thing I've found. It looks fiendishly complex, rather delicate, and I'm not sure it would work for my application.
Is there a more straightforward way for me to do something like supply a GPX file (like I do for Xcode) to spoof a location?
I am using a Mac, and can use pretty much any browser to do this.
Thanks!
OK. I figured out how to do this in Chrome.
It is almost the same as this (The solution I mentioned in the question).
However, Google seems to have moved things around. You no longer have the "Emulation" tab. What you have is a "Sensors" tab that appears in the second Developer panel:
In here, you can play with it.

Can't use PhoneGap's geolocaiton API; Safari always used instead. Ugly geolocation prompt appears

I have a Sencha app which performs geolocation, and provides a list of nearby venues based on the results.
I am using PhoneGap:Build (the automated service); this point might be of importance. I am not dealing with the PhoneGap files at all - I am letting PhoneGap:Build automatically create the apps for all platforms. So far it has been spectacular.
The problem: I understand that attempting to geolocate before 'deviceready' is triggered may result in a geolocation call using the Safari geolocation instead of the device geolocation. The side-effect I am experiencing is this terrible message prompt:
'/var/mobile/Applications/XXXX-XXXX-XXXX-XXXXXXXXXXX/AppName.app/www/index.html would like to use your current location'
Now, this is still happening after I introduce even a 10 second delay - long enough to ensure that PhoneGap has long since been loaded. This is where I am confused. This only happens in iOS; Android build seems fine.
Why am I getting this message? I have the following line in my config.xml:
<feature name="http://api.phonegap.com/1.0/geolocation"/>
..Which I figured was sufficient to open up the PhoneGap geolocation API, thus avoiding this horrible message.
I should also note that I get double prompted; the first time geolocation is performed, I get this:
'App Name would like to use your location'
Which is then followed by a second message - the ugly one I outlined above.
Why are two prompts being displayed back-to-back? Why not just the first one? I've spent days on this.. completely out of ideas. Please help!
This same issue is addressed
here.
Basically they again take you
here.
which explains a fairly in depth process but at least it works.

Google Maps Gadget Not Working

I'm not sure of the specific day, but on our company site, the Google Maps Driving Directions Gadget no longer functions, i.e. it is no longer accepting input and autoexpanding the directions. This is the standard gadget found at http://maps.google.com/help/maps/gadgets/directions/. I was just curious if anyone else is experiencing this issue, or is there a known conflict with jQuery or any other popular scripts?
This seems to be an issue that is not only related to your site. We had the directions widget on a test server and it used to run fine. Last week I noticed it would not expand in IE and FF anymore, Chrome however is working fine.
I did some searching around on the net and there are other people having the same issues:
Google support page
Another Google support page
So this seems to be an issue with the Google code and we need to wait for them to fix it.

Categories

Resources