How to display weather data based on the browser location in cq5? - javascript

I need to display the weather information based on my location. Is there any API to do the same?

there is a good post how to use the geolocation from the clientcontext here http://blogs.adobe.com/livecycle/2011/10/bringing-geo-location-to-web-experience-management.html
that might give you a good start

Related

Is there any way to get all the media with information by one API request Instagram Graph API?

Facebook recently changes its Instagram API. Now I can get all the media ids by requesting from this endpoint-
https://graph.facebook.com/v7.0/{ig-user-id}/media?access_token=...
But it only returns the media Ids, not any other media information such as caption, media_url, comments_count, likes_count etc.
For getting these data, I have to request from the API-
https://graph.facebook.com/v7.0/{ig-media-id}?fields=caption,media_url,comments_count&access_token=...
This is working well but the problem is I have to hit this API for each and every {ig-media-id} which is not a good thing.
So, is there any way to get all the media with information (caption, media_url, comments_count, likes_count) by one API request like-
https://graph.facebook.com/v7.0/{ig-user-id}/media?fields=caption,media_url&access_token=...
I solve the problem using Nested Request. Special thanks to #Cbroe.
I've gained the result by using one query after changing the 1st API like this-
https://graph.facebook.com/v7.0/{ig-user-id}?fields=media.limit(4){id,caption,media_url}&access_token=...

Users check-in location based where to start?

Im working on App using React Native using user location, what i wanna do is while app is closed to check if user is at a location that already exists in the database and if he is
Show a notification saying “ are you at John Doe place “
So to get started i need to know what’s needed to check user location in the background, and then compare the user location in the database and get the results if he is at some location that exists in the database show notifications
Any place where i should start ?
You will probably have to have:
Previously requested the appropriate rights to the user (location, notifications,..)
A background task running periodically or a watcher on the user's position
A way to access the user's
location (see navigator.geolocation.getCurrentPosition(...) or navigator.geolocation.watchPosition(...))
You can combine that with network calls and notifications and you should be able to get to the desired behavior.
This example may help you getting started.
You can use the Geolocation API to get user location, if they permit the app to know their location. I'd add it to a snippet here but stackoverflow has disabled use of the Geolocation API.
const successCallback = positionObj => console.log(positionObj);
const errorCallback = positionError => console.error(positionError);
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
Working JSFiddle here.

Not able to fetch Latitude and longitude from eventbrite api

This is a query string to fetch all popular events within a radius of a specified location.
https://www.eventbriteapi.com/v3/events/search/?popular=off&location.address="+area+"&location.within="+radius+"&token=E5DRAICK4272QQQIBDR5
But when I query Eventbrite api I only get venue_id , How to fetch lat and long for an event from eventbrite api ?
Please try venue param in your fetching URL to eventBrite API, like this:
$search_url?token=$token&q=&date_created.keyword=today&page=$repeat&sort_by=$date&expand=venue
It solved my issue and brought lat long along with proper location of event.
&expand=venue is still working perfectly!!! The official documentation says the venue is deprecated, but anyway you can use it.

HTML5 Server Geolocation (NOT client location)

I use the HTML5 implementation of gelocation (navigator.geolocation) to show client location on a google map, using the Google maps API. This is easy.
What I would like, however, is to also put the server location on a map, i.e. 'you are here, your server is here'. I cannot see how to easily do this.
I could just scrape a page like whatsmyip for coordinates, but it seems like this should be built into the API. Am I just missing it?
Thanks,
Colin
The HTML5 geolocation api is implemented by the browser and uses a mix of information potentially including WiFi signals, IP address, or a GPS module. It does not have access to that information for the sever, nor is it common to care about the sever location.
All of which is to say the HTML5 geolocation api does support locating the server and you will need to provide the coordinates by some other means (most likely some form of Geo IP database).
I just scraped using php:
function ip_details($ip) {
//$json = file_get_contents("http://ipinfo.io/{$ip}");
$json = file_get_contents("http://ipinfo.io/");
$details = json_decode($json);
return $details;
}
$details = ip_details("8.8.8.8");
$_SESSION['user']['serverextip'] = $details->ip;
$_SESSION['user']['serverloc'] = $details->loc;

How to get the zipcode of a user using AngularJS

I need to populate some data based on the zipcode of the user visiting the site.
Could somebody tell me how to retrieve the zipcode of the location of that user?
I am using AngularJS on my app.
OK. It is a bit involved, but here is how I would do it, if I were you.
First, you would use the geolocation API as follows:
window.navigator.geolocation.getCurrentPosition(function(pos){
console.log(pos);
});
Inside your callback, you will get a position object. It looks like this:
{
"timestamp":1408324851386,
"coords"{
"speed":null,
"heading":null,
"altitudeAccuracy":null,
"accuracy":30,
"altitude":null,
"longitude":-111.8942634,
"latitude":40.7288257
}
}
Then, you can take the latitude and longitude and call your server to translate it into a ZIP code. Getting the lat/long is the hard part. Doing the math to turn that into a zip is easy.
An alternative to calling your own server to translate the lat/long into a zip, you could call Google Maps' reverse lookup API. You give it a lat long, and it gives you an address, complete with a ZIP. See HERE for how to do that.
DISCLAIMER: This won't work in IE8, as the geolocation API wasn't introduced until IE9. It will work in all other browsers (besides Opera Mini, #NBD).
HERE IS A FULL WORKING EXAMPLE
I just tried this out, and it found my house, no problem.
window.navigator.geolocation.getCurrentPosition(function(pos){
console.log(pos);
$http.get('http://maps.googleapis.com/maps/api/geocode/json?latlng='+pos.coords.latitude+','+pos.coords.longitude+'&sensor=true').then(function(res){
console.log(res.data);
});
})
There doesn't seem to be any built-in method for determining this, you'll have to use a map service or zipcode database.

Categories