Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    390
    Thanks
    48
    Thanked 1 Time in 1 Post

    Question Help on finding world weather based on the visitors longitude and latitude?

    Hello,

    Anywhere in the world the visitor is on my website, if they give my website permissions, the website will know their longitude and latitude. From this information, I need to find out their:

    • Weather - For example: Sunny, Showers
    • Temperature:
    • > Current - Example: 10°C
    • > High - Example: 20°C
    • > Low - Example: 5°C
    • Humidity - Example: 83%
    • Visibility - Example: Good
    • Pressure (Millibars) - Example: 996
    • Wind Direction - Example: ENE
    • Wind Speed mph - Example: 2mph


    Basically, I need as much information as I can get to be able to show on my own website as you see on: http://www.bbc.co.uk/weather/2643123

    The BBC does offer an RSS Feed: http://open.live.bbc.co.uk/weather/f...ayforecast.rss

    However I need one which you can use with the visitors longitude and latitude for anywhere in the world and I am not sure if there are any services which provide this, whether I need to include multiple for the different countries or whatnot and could really do with some help.

    Thank you for any help and/or advice in answering my question.

    Best Regards,
    Tim

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,495
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    How far are you with your script?

    Are you at a point where you can use the Google Map V3 locator to provide you with a city and country? Can you demo that for us on a web page?

    Once you can get the city and country of a user, it will be easy (easier) to get the weather info.

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    390
    Thanks
    48
    Thanked 1 Time in 1 Post
    I am currently setting up a HTML5 Geolocation API on my website. There is currently no live demo which I can yet provide.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,495
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Once you can get a country and city, you go to weatherunderground and register for an API key. The key is free to use for up to 500 lookups per day. More than that, you'll need to pay a monthly fee.

    A PHP script can use CURL to grab the XML file for your designated city.

    Example, when I access this XML file, I get the results shown below:

    http://api.wunderground.com/api/mykeygoeshere/conditions/q/UK/Manchester.xml

    So with Google Maps locator, you'll need to know the country name ( UK ) and the city ( Manchester ).
    Examples in the U.S. would be: /MN/Minneapolis.xml (state/city).


    XML Results:
    PHP Code:

    <response>
    <
    version>0.1</version>
    <
    termsofService>http://www.wunderground.com/weather/api/d/terms.html</termsofService>
    <features>
    <
    feature>conditions</feature>
    </
    features>
    <
    current_observation>
    <
    image>
    <
    url>http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png</url>
    <title>Weather Underground</title>
    <
    link>http://www.wunderground.com</link>
    </image>
    <
    display_location>
    <
    full>ManchesterUnited Kingdom</full>
    <
    city>Manchester</city>
    <
    state/>
    <
    state_name>United Kingdom</state_name>
    <
    country>UK</country>
    <
    country_iso3166>GB</country_iso3166>
    <
    zip>00000</zip>
    <
    latitude>53.34999847</latitude>
    <
    longitude>-2.26999998</longitude>
    <
    elevation>78.00000000</elevation>
    </
    display_location>
    <
    observation_location>
    <
    full>Manchester, </full>
    <
    city>Manchester</city>
    <
    state/>
    <
    country>UK</country>
    <
    country_iso3166>GB</country_iso3166>
    <
    latitude>53.34999847</latitude>
    <
    longitude>-2.26999998</longitude>
    <
    elevation>256 ft</elevation>
    </
    observation_location>
    <
    estimated>
            </
    estimated>
            <
    station_id>EGCC</station_id>
            <
    observation_time>Last Updated on March 2012:50 AM GMT</observation_time>
            <
    observation_time_rfc822>Wed20 Mar 2013 00:50:00 +0000</observation_time_rfc822>
            <
    observation_epoch>1363740600</observation_epoch>
            <
    local_time_rfc822>Wed20 Mar 2013 01:08:22 +0000</local_time_rfc822>
            <
    local_epoch>1363741702</local_epoch>
            <
    local_tz_short>GMT</local_tz_short>
            <
    local_tz_long>Europe/London</local_tz_long>
            <
    local_tz_offset>+0000</local_tz_offset>
            <
    weather>Mostly Cloudy</weather><temperature_string>37 F (3 C)</temperature_string>
            <
    temp_f>37</temp_f>
            <
    temp_c>3</temp_c>
            <
    relative_humidity>81%</relative_humidity>
            <
    wind_string>From the East at 8 MPH</wind_string>
            <
    wind_dir>East</wind_dir>
            <
    wind_degrees>80</wind_degrees>
            <
    wind_mph>8</wind_mph>
            <
    wind_gust_mph>0</wind_gust_mph>
            <
    wind_kph>13</wind_kph>
            <
    wind_gust_kph>0</wind_gust_kph>
            <
    pressure_mb>1001</pressure_mb>
            <
    pressure_in>29.56</pressure_in>
            <
    pressure_trend>0</pressure_trend>
            <
    dewpoint_string>32 F (0 C)</dewpoint_string>
            <
    dewpoint_f>32</dewpoint_f>
            <
    dewpoint_c>0</dewpoint_c>
            <
    heat_index_string>NA</heat_index_string>
            <
    heat_index_f>NA</heat_index_f>
            <
    heat_index_c>NA</heat_index_c><
            
    windchill_string>31 F (0 C)</windchill_string>
            <
    windchill_f>31</windchill_f>
            <
    windchill_c>0</windchill_c>
            <
    feelslike_string>31 F (0 C)</feelslike_string>
            <
    feelslike_f>31</feelslike_f>
            <
    feelslike_c>0</feelslike_c>
            <
    visibility_mi>6.2</visibility_mi>
            <
    visibility_km>10.0</visibility_km>
            <
    solarradiation/><UV>0</UV>
            <
    precip_1hr_string>-9999.00 in (-9999.00 mm)</precip_1hr_string>
            <
    precip_1hr_in>-9999.00</precip_1hr_in>
            <
    precip_1hr_metric>-9999.00</precip_1hr_metric>
            <
    precip_today_string>0.00 in (0.0 mm)</precip_today_string>
            <
    precip_today_in>0.00</precip_today_in>
            <
    precip_today_metric>0.0</precip_today_metric>
            <
    icon>mostlycloudy</icon>
            <
    icon_url>http://icons-ak.wxug.com/i/c/k/nt_mostlycloudy.gif</icon_url>
            
    <forecast_url>http://www.wunderground.com/global/stations/03334.html</forecast_url>
            
    <history_url>http://www.wunderground.com/history/airport/EGCC/2013/3/20/DailyHistory.html</history_url>
            
    <ob_url>http://www.wunderground.com/cgi-bin/findweather/getForecast?query=53.34999847,-2.26999998</ob_url>
            
    </current_observation>
            </
    response
    PHP can parse that XML file and dynamically generate any web page you wish. There are many different API reports and data collections to access.

    Even if you have to pay a monthly fee, look at how much data you can get.

    See this for more info:
    http://www.wunderground.com/weather/api/d/docs


    .
    Last edited by mlseim; 03-20-2013 at 02:23 AM.

  • #5
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    check this out.
    it says it's depracted, but i see that text since long long time and they don't take it offline, so i guess you can use it for now
    http://api.wunderground.com/auto/wui...,-122.39418793
    it will give you nearest stations to use with mlseim's example

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,495
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    patryk ...

    I suppose you could use that 'old' API to get nearby location information based on GPS coordinates. It would take a bit more scripting and still the other API would need to be used for the actual weather reports. A person would have to experiment and see if the Google map locator even gets you close to where you really are.

    When I use the Google locator, it sometimes gets me in the Twin Cities (Minnesota) where I'm located. Other times it puts me closer to South Dakota. Even though the location is off by only 300 miles, that makes a difference in the weather. That Google locator thing is just not reliable (in my opinion).

    Most people know what city and state (or country) they are currently at. One might think that it would be easiest to just enter that in. We don't know the original intent of the OP.

  • #7
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    i actually found one free api with coordinates based lookup
    http://www.myweather2.com/developer/...b-d771a92b9dbf

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,495
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    That could be an interesting one to try. I've never used that one before.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •