Geolocation on NW.js returns error code 400

Bugs will be moved here once resolved.

Post » Sun May 14, 2017 9:56 pm

Problem Description
Hi everyone.

When requesting the location with the native Geolocation plugin under an NW.js export or preview, the event "On error" triggers, the error message is:
"Network location provider at 'https //www.googleapis.com/' returned error code 400"

This seems to be related to NW.js only.
I googled the error message, some results said it's related to Google Chrome (would make sense, NW.js uses Chromium), but when previewing in Chrome (not NW.js), everything works.

I'm no programmer, but I would assume, this problem is related to NW.js, not C2.
But maybe there's a workaround to get it to work (apart from not using NW.js, obviously) without having to rely on an NW.js update.

Capx
You can use the default Geolocation template.

Description of Capx
Testing the Geolocation plugin to its full content.

Steps to Reproduce Bug
  1. Use either action Request location or Track location
  2. When previewing in or running the exported NW.js, On error will trigger
  3. The expression Geolocation.ErrorMessage will be the above-mentioned message

Observed Result
See steps above.

Expected Result
The event On location update should trigger and the expressions Geolocation.Longitude and Geolocation.Latitude should return the approximate location.

Affected Browsers
  • Chrome: (NO)
  • FireFox: (NO)
  • Internet Explorer: (NO)
  • NW.js: (YES)

Operating System and Service Pack
Windows 7 64bit, SP1

Construct 2 Version ID
Construct 2 r244, most current NW.js (v0.22.0 (Chromium 58)), released 20th of April 2017.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Wed May 17, 2017 1:08 am

Found this post on the nw.js Github.

I don't have a clue when it comes to javascript, can anyone make use of this and modify the Geolocation plugin?
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Wed May 17, 2017 1:28 am

Just run it through the ajax plug.
Then load lastdata into something that can parse it like Yanns Json plug.

This one:
http://freegeoip.net/json/

Came back with the wrong city, in the wrong state.
Image ImageImage
B
168
S
50
G
164
Posts: 8,228
Reputation: 105,575

Post » Thu May 18, 2017 7:06 pm

Thanks for the answer, this is actually almost what I ended up doing!

With the only difference that I'm using this address now:
https://maps.googleapis.com/maps/api/browserlocation/json?browser=chromium&sensor=true

It seemed more accurate to me.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Fri Jun 23, 2017 5:23 pm

I guess Google now block Geolocation from non-Chrome browsers. I added the workaround for the next build of C2 which looks like it works, hopefully they allow that one to keep running...
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,454


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests