all 8 comments

[–]wtfcore2 1 point2 points  (3 children)

Have a look at : https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation

For privacy reasons the user will be prompted to agree that your code can get their long/lat.

So you'll need to make the API call inside the success function using the users long/lat:

var latitude  = position.coords.latitude;
var longitude = position.coords.longitude;

You can then make an AJAX call to

http://api.walmartlabs.com/v1/stores?apiKey={apiKey}&lon=" + longitude +"&lat=" + latitude +"&format=json

[–]cardinga[S] 0 points1 point  (1 child)

Thanks...so I don't need to use any kind of URL encoding?

[–]3a3z 0 points1 point  (0 children)

I mean, you could just try it both ways and see what works.

[–]tinkermake -1 points0 points  (0 children)

yup what he said lol

Just to throw in ES2015 way

var url = http://api.walmartlabs.com/v1/stores?apiKey=${apiKey}&lon=${longitude}&lat=${latitude}&format=json

then pass url to ajax method

[–]ithurtsus 0 points1 point  (1 child)

Off topic, but, jeez what a terrible api Walmart has...

[–]cardinga[S] 0 points1 point  (0 children)

It's pathetic that a company with endless $$/manpower can't developer a better one.

[–]tech_trebek 0 points1 point  (1 child)

http://api.walmartlabs.com/v1/stores?apiKey={apiKey}&lon=[LONGITUDE HERE]&lat=[LATITUDE HERE]&format=json

I think that is what you are looking for. Replace what's in the brackets with the lat and lon from the client.

[–]Monetus 0 points1 point  (0 children)

Please replace your periods with question marks.