Yahoo Geolocation API To Get Latitude and Longitude

This post is an example for yahoo placefinder.Using which latitude and longitude of the places can be obtained.This could be useful when your application needs to keep track of the places in a database and later display it in the map.Most popularly used google maps,yahoo maps requires latitude and longitude of places.These codes should be helpful to get the latitude and longitude.

WHY YAHOO?

 There is no reason for it because google’s geocoder api is also simple but when comes to usage limits per day yahoo gives little more than google.

Technologies Used:

  • Jquery
  • yahoo api
yahoo geolocation api

yahoo geolocation api

Whats special?

Code is so simple ! Requires only a simple ajax call to geocode.

 

demo

GEOCODE.PHP:

This code echo’s the content as a xml format to the front end.

<?php
$search= "http://where.yahooapis.com/geocode?location=".$_POST['location']."";
$xml = simplexml_load_file($search,'SimpleXMLElement', LIBXML_NOCDATA);
echo $xml->asXML();
?>

 INDEX.HTML( Ajax call ):

$.post('geocode.php',{location:location_value},
	function(output)
	{
             $(lat).html($(output).find('latitude').text());
             $(lon).html($(output).find('longitude').text());
             $(result).fadeIn();
             $(loader).fadeOut();
	});

Webtuts going to make tutorial on google maps API in the upcoming weeks where these latitudes and longitudes will be used in the map.Subscribe us and stay connected.

Thats it ! Any queries leave a comment below.

 

0saves
If you like this post, contribute us by sharing this in your network

  • Guest

    The demo is displaying the longitude as the latitude as well; change this line:
        $(lon).html($(output).find(‘latitude’).text());
    to:    $(lon).html($(output).find(‘longitude’).text());

  • Anonymous

    Thanks for pointing it out.

  • http://www.greenplanet4energy.com building a solar panel

    building a solar panel…

    I’m really enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a designer to create your theme? Superb work!…

  • http://www.facebook.com/jeroenvangijzel Jeroen van Gijzel

    This API doesn’t seem to work anymore since today, is anyone else familiar with this problem?

    I can see your request to Yahoo gives the same error:

    Warning: simplexml_load_file(http://where.yahooapis.com/geocode?location=Amsterdam) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
    in /home/content/61/8647061/html/demo/geocode/geocode.php on line 3

    Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://where.yahooapis.com/geocode?location=Amsterdam&quot; in /home/content/61/8647061/html/demo/geocode/geocode.php on line 3

    Fatal error: Call to a member function asXML() on a non-object in /home/content/61/8647061/html/demo/geocode/geocode.php on line 4

  • Anonymous

    Hey Jeron, Thanks for notifying to me.As you said this API is currently stopped by yahoo.For the latest one implementation you can refer -http://developer.yahoo.com/boss/geo/ . Hopefully we does a post with this implementation soon.Subscribe Us for further updates from WEBTUTS

Ver peliculas online