Yahoo map service php tutorial
Yahoo provides simple, great maps service to be handled with php, if you need a fast dynamic solution for your website or web service, yahoo MapService api returns images of geo locations by request url. We will show you basic usage of yahoo maps with zoom in and zoom out. You can send the requests using ajax technology and to create the application much better with zoom in and zoom out scroller.
The code is in front of you , you will need to get yahoo api developer key before, and to add it in request url :
<?php
$request = ‘http://local.yahooapis.com/MapsService/V1/mapImage?appid=YOUR_API_KEY&couuntry=germany&city=berlin&radius=’.$zoom.’&output=php’;
$response = file_get_contents($request);
if ($response === false) {
die(’Request failed’);
}
$phpobj = unserialize($response);
echo ‘<img src=”‘.$phpobj["Result"].’” alt=”" />’;
?>
let’s take a look at our request url, and here is the list of GET variables for proper API response :
- appid – is your application api key , you should get it on yahoo api request page.
- couuntry – is the country you are looking for
- city – is the city in mentioned country
- radius – the location radius in km.
- output – is the language used for the api response , in our case it is php.
$request = ‘http://local.yahooapis.com/MapsService/V1/mapImage?appid=YOUR_API_KEY&couuntry=israel&city=haifa&radius=0&output=php’;
It’s really simple and could be used as a great resourse for maps inside of application.
Have fun.
