New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any plan about Geolocation #236

Open
roughsoft opened this Issue Dec 5, 2012 · 20 comments

Comments

Projects
None yet
@roughsoft

roughsoft commented Dec 5, 2012

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@ghost ghost assigned rogerwang Dec 13, 2012

@andrewthornton

This comment has been minimized.

Show comment
Hide comment
@andrewthornton

andrewthornton Jan 7, 2014

Just curious if there is any update on this?

andrewthornton commented Jan 7, 2014

Just curious if there is any update on this?

@sdog869

This comment has been minimized.

Show comment
Hide comment
@sdog869

sdog869 Jan 11, 2014

It would be nice if we could specify the permission in the manifest and not have to ask the user for this, I think it's a jarring experience to the user in app. Thanks!

sdog869 commented Jan 11, 2014

It would be nice if we could specify the permission in the manifest and not have to ask the user for this, I think it's a jarring experience to the user in app. Thanks!

@pwlin

This comment has been minimized.

Show comment
Hide comment
@pwlin

pwlin Jan 28, 2014

It is highly probable that the desktop machine running your node-webkit app does not have GPS hardware capabilities. In that case you just have to tap into the same Google Geolocation API as navigator.geolocation.getCurrentPosition, namely, a simple xmlhttp call to:

https://maps.googleapis.com/maps/api/browserlocation/json?browser=chromium&sensor=true

which will return a json string such as:

{
 "accuracy" : XXXX,
 "location" : {
   "lat" : XX.XX,
   "lng" : XX.XX
 },
 "status" : "OK"
}

Now you can write your own getCurrentPosition()

navigator.geolocation = {};
navigator.geolocation.getCurrentPosition = function(callback) {
    $.get('https://maps.googleapis.com/maps/api/browserlocation/json?browser=chromium&sensor=true', function(data) { 
        var position = {
            coords : {
                latitude : data.location.lat,
                longitude : data.location.lng
            }
        };
        callback(position);
    });
};

Instead of Google Geolocation API, you can also use

http://freegeoip.net/json/

pwlin commented Jan 28, 2014

It is highly probable that the desktop machine running your node-webkit app does not have GPS hardware capabilities. In that case you just have to tap into the same Google Geolocation API as navigator.geolocation.getCurrentPosition, namely, a simple xmlhttp call to:

https://maps.googleapis.com/maps/api/browserlocation/json?browser=chromium&sensor=true

which will return a json string such as:

{
 "accuracy" : XXXX,
 "location" : {
   "lat" : XX.XX,
   "lng" : XX.XX
 },
 "status" : "OK"
}

Now you can write your own getCurrentPosition()

navigator.geolocation = {};
navigator.geolocation.getCurrentPosition = function(callback) {
    $.get('https://maps.googleapis.com/maps/api/browserlocation/json?browser=chromium&sensor=true', function(data) { 
        var position = {
            coords : {
                latitude : data.location.lat,
                longitude : data.location.lng
            }
        };
        callback(position);
    });
};

Instead of Google Geolocation API, you can also use

http://freegeoip.net/json/
@aalaap

This comment has been minimized.

Show comment
Hide comment
@aalaap

aalaap Mar 2, 2014

@pwlin that was amazing! thanks for this.

aalaap commented Mar 2, 2014

@pwlin that was amazing! thanks for this.

@brettfattori

This comment has been minimized.

Show comment
Hide comment
@brettfattori

brettfattori May 26, 2014

That's awesome. I'll use that until there is native support for GeoLocation. I'm okay with a system level prompt for permissions, but it would be nice to be able to "remember" what their choice was and use that so it doesn't ask again.

brettfattori commented May 26, 2014

That's awesome. I'll use that until there is native support for GeoLocation. I'm okay with a system level prompt for permissions, but it would be nice to be able to "remember" what their choice was and use that so it doesn't ask again.

@sgsaravana

This comment has been minimized.

Show comment
Hide comment
@sgsaravana

sgsaravana Nov 27, 2014

@pwlin : Thanks for that.
You can use the following code to get the map image with the coordinates

function showPosition(position) {
    var latlon = position.coords.latitude + "," + position.coords.longitude;
    var img_url = "http://maps.googleapis.com/maps/api/staticmap?center=
    "+latlon+"&zoom=14&size=400x300&sensor=false";
    document.getElementById("mapholder").innerHTML = "<img src='"+img_url+"'>";
}

And use this if you want an interactive map:
http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation_map_script

sgsaravana commented Nov 27, 2014

@pwlin : Thanks for that.
You can use the following code to get the map image with the coordinates

function showPosition(position) {
    var latlon = position.coords.latitude + "," + position.coords.longitude;
    var img_url = "http://maps.googleapis.com/maps/api/staticmap?center=
    "+latlon+"&zoom=14&size=400x300&sensor=false";
    document.getElementById("mapholder").innerHTML = "<img src='"+img_url+"'>";
}

And use this if you want an interactive map:
http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation_map_script

@outaTiME

This comment has been minimized.

Show comment
Hide comment
@outaTiME

outaTiME May 10, 2015

Any plan for this feature ???

For now im using the @pwlin solution the navigator.geolocation.watchPosition and navigator.geolocation.getCurrentPosition no asking for permissions then ... nothing happens =(

outaTiME commented May 10, 2015

Any plan for this feature ???

For now im using the @pwlin solution the navigator.geolocation.watchPosition and navigator.geolocation.getCurrentPosition no asking for permissions then ... nothing happens =(

@shaynem

This comment has been minimized.

Show comment
Hide comment
@shaynem

shaynem May 10, 2015

Why wouldn't you just use a http call to one of the many Geolocation
services or use a npm package with maxmind db

It's better then a browser warning asking for the users location which
html5 gives.
On 11 May 2015 4:06 am, "Ariel Falduto" notifications@github.com wrote:

Any plan for this feature ???


Reply to this email directly or view it on GitHub
#236 (comment).

shaynem commented May 10, 2015

Why wouldn't you just use a http call to one of the many Geolocation
services or use a npm package with maxmind db

It's better then a browser warning asking for the users location which
html5 gives.
On 11 May 2015 4:06 am, "Ariel Falduto" notifications@github.com wrote:

Any plan for this feature ???


Reply to this email directly or view it on GitHub
#236 (comment).

@outaTiME

This comment has been minimized.

Show comment
Hide comment
@outaTiME

outaTiME May 12, 2015

Im working on a mixed solution single webpage:

  1. node-webkit desktop app pointing to remote webpage (where the http call is fine).
  2. web page in browsers where the html5 geolocation feature may be use the GPS on devices with this capabilities.

it will be great to get transparent code here native in node-webkit and use for example the macos location service (in desktop):

screen shot 2015-05-12 at 14 16 00

outaTiME commented May 12, 2015

Im working on a mixed solution single webpage:

  1. node-webkit desktop app pointing to remote webpage (where the http call is fine).
  2. web page in browsers where the html5 geolocation feature may be use the GPS on devices with this capabilities.

it will be great to get transparent code here native in node-webkit and use for example the macos location service (in desktop):

screen shot 2015-05-12 at 14 16 00

@outaTiME

This comment has been minimized.

Show comment
Hide comment
@outaTiME

outaTiME May 31, 2015

Checkout the browserlocation request accuracy compared with the apple core location response (in the same iMac)

browserlocation:

screen shot 2015-05-31 at 15 39 48

core location:

screen shot 2015-05-31 at 15 41 18

It is not acceptable in any way, but if you use the getCurrentLocation from browser:

screen shot 2015-05-31 at 15 46 19

I insist, IMHO nw.js must give native support for geolocation ...

outaTiME commented May 31, 2015

Checkout the browserlocation request accuracy compared with the apple core location response (in the same iMac)

browserlocation:

screen shot 2015-05-31 at 15 39 48

core location:

screen shot 2015-05-31 at 15 41 18

It is not acceptable in any way, but if you use the getCurrentLocation from browser:

screen shot 2015-05-31 at 15 46 19

I insist, IMHO nw.js must give native support for geolocation ...

@outaTiME

This comment has been minimized.

Show comment
Hide comment
@outaTiME

outaTiME May 31, 2015

Note, using geolocation service from google i get unacceptable accuracies to (the same as browserlocation service):

https://developers.google.com/maps/documentation/business/geolocation/

screen shot 2015-05-31 at 16 01 50

We get the better results using the core location from apple or the native browser geolocation support ...

outaTiME commented May 31, 2015

Note, using geolocation service from google i get unacceptable accuracies to (the same as browserlocation service):

https://developers.google.com/maps/documentation/business/geolocation/

screen shot 2015-05-31 at 16 01 50

We get the better results using the core location from apple or the native browser geolocation support ...

@outaTiME

This comment has been minimized.

Show comment
Hide comment
@outaTiME

outaTiME Jul 15, 2015

Updates ??

outaTiME commented Jul 15, 2015

Updates ??

@luannpeixe

This comment has been minimized.

Show comment
Hide comment
@luannpeixe

luannpeixe commented Mar 29, 2016

nothing =(

@rogerwang

This comment has been minimized.

Show comment
Hide comment
@rogerwang

rogerwang Mar 29, 2016

Member

It should be easily supported in 0.13. Will check it.

Member

rogerwang commented Mar 29, 2016

It should be easily supported in 0.13. Will check it.

@rogerwang rogerwang added the nw13 label Mar 29, 2016

@tomekmarchi

This comment has been minimized.

Show comment
Hide comment
@tomekmarchi

tomekmarchi Apr 22, 2016

Still no support for this?

tomekmarchi commented Apr 22, 2016

Still no support for this?

@hstarorg

This comment has been minimized.

Show comment
Hide comment
@hstarorg

hstarorg May 13, 2016

Can fake geolocation?

hstarorg commented May 13, 2016

Can fake geolocation?

@luannpeixe

This comment has been minimized.

Show comment
Hide comment
@luannpeixe

luannpeixe May 23, 2016

@rogerwang Yes, navigator.geolocation work now. But generate error!

PS: Tested on 0.14 and 0.15 version...

See:

PositionError {code: 2, message: "Network location provider at 'https://www.googleapis.com/' : Returned error code 400."}
code
:
2
message
:
"Network location provider at 'https://www.googleapis.com/' : Returned error code 400."
proto
:
PositionError

luannpeixe commented May 23, 2016

@rogerwang Yes, navigator.geolocation work now. But generate error!

PS: Tested on 0.14 and 0.15 version...

See:

PositionError {code: 2, message: "Network location provider at 'https://www.googleapis.com/' : Returned error code 400."}
code
:
2
message
:
"Network location provider at 'https://www.googleapis.com/' : Returned error code 400."
proto
:
PositionError

@jtg-gg

This comment has been minimized.

Show comment
Hide comment
@jtg-gg

jtg-gg May 24, 2016

Member

@rogerwang I've a working implementation using OS geo-location capability, but it will only work on Win 8 or newer and OSX, here is my pull request nwjs/chromium.src#20

The google chrome implementation, will need google api key, so I implement it using OS geo-location capability

Member

jtg-gg commented May 24, 2016

@rogerwang I've a working implementation using OS geo-location capability, but it will only work on Win 8 or newer and OSX, here is my pull request nwjs/chromium.src#20

The google chrome implementation, will need google api key, so I implement it using OS geo-location capability

@blaremc

This comment has been minimized.

Show comment
Hide comment
@blaremc

blaremc commented Mar 13, 2017

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment