-1

I tried Google place API, it's returning phone for a place "formatted_phone_number" or "international_phone_number".

But it is not returning for all places (just for 1 in 100 places). But, Currently I want to get phone number for each place (For example :- Hotel ).

I will send the Latitude and Longitude information to API it need to return nearest Hotel address and Phone number as well.

Please suggestion me better API for this.

Naga Harish M
  • 2,779
  • 2
  • 31
  • 45
  • The Places API returns phone numbers for a place if the data is available. Unfortunately in some areas Place data may not be this complete. If you know the phone numbers or more information about these places you can add it using Google Map Maker: http://www.google.com/mapmaker – Chris Green May 04 '12 at 00:18

1 Answers1

2

Quality of the data (such as phone numbers) that you can receive from any Places API depends purely upon the quality of the data backing up that API. This will vary from vendor to vendor and coverage will differ from country to country, city to city and so on.

Your best bet here would be to run some sort of "beauty contest" to get a feel for which vendor holds the best data set that is relevant to you.

To get the phone number of a place using the Nokia RESTful Places API for example, is a two stage process:

  • make a general category query e.g "Hotels" near "Mumbai"

http://places.nlp.nokia.com/places/v1/discover/search?at=18.975%2C72.825833&q=hotel&tf=plain&pretty=y&size=10&app_id=_peU-uCkp-j8ovkzFGNU&app_code=gBoUkAMoxoqIWfxWA5DuMQ

  • Take the placeId, and query for more information such as contacts.phone

http://places.nlp.nokia.com/places/v1/places/356te7gc-e5c2e62e24254695b4e41c7762ded586;context=Zmxvdy1pZD03NTAwNzM3ZS1mZmEwLTU0ZDgtYjBkZC1lYjgwMDZmMGE2NDBfMTM1OTcwODg5MDQzNl8wXzU2ODAmcmFuaz0x?app_id=_peU-uCkp-j8ovkzFGNU&app_code=gBoUkAMoxoqIWfxWA5DuMQ

Again not all places will contain phone information. Now you could chain the response from the first request to loop through the placeIds received and place the phone numbers on screen.

An alternative would be to use the existing JavaScript API wrapper to display information as shown in the code below, you'll need your own app id and token to get it to work

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- 
    Example from Nokia Maps API Playground, for more information visit http://api.maps.nokia.com
 -->
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9"/>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <title>Nokia Maps API Example: Search by category</title>
        <meta name="description" content="Search by category"/>
        <meta name="keywords" content="search, services, places, category"/>
        <!-- For scaling content for mobile devices, setting the viewport to the width of the device-->
        <meta name=viewport content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <!-- By default we add ?with=all to load every package available, it's better to change this parameter to your use case. Options ?with=maps|positioning|places|placesdata|directions|datarendering|all -->
        <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.3/jsl.js?with=all"></script>
        <!-- JavaScript for example container (NoteContainer & Logger)  -->
        <style type="text/css">
            html {
                overflow:hidden;
            }

            body {
                margin: 0;
                padding: 0;
                overflow: hidden;
                width: 100%;
                height: 100%;
                position: absolute;
            }

            #mapContainer {
                width: 40%;
                height: 80%;
                left: 0;
                top: 0;
                position: absolute;
            }
            #progress {
                width: 80%;
                height: 10%;
                left: 0;
                top: 80%;
                position: absolute;
            }
            #buttons {
                width: 80%;
                height: 10%;
                left: 0;
                top: 90%;
                position: absolute;
            }
        </style>
    </head>
    <body>
        <div id="mapContainer"></div>
        <div id="progress"></div>
        <div id="buttons">
         <a onClick="searchByCategory( map.center, 'bookshop' );return false;" href="#">Find Hotels</a> 
          <div style="display:block">
         <div id="csPlaceWidget" style="display:none"></div>
         </div>

        </div>

        <script type="text/javascript" id="exampleJsSource">
/*  Set authentication token and appid 
*   WARNING: this is a demo-only key
*   please register on http://api.developer.nokia.com/ 
*   and obtain your own developer's API key 
*/
nokia.Settings.set("appId", "My App Id"); 
nokia.Settings.set("authenticationToken", "My Token");


// Get the DOM node to which we will append the map
var mapContainer = document.getElementById("mapContainer");
var infoBubbles = new nokia.maps.map.component.InfoBubbles();   

// Create a map inside the map container DOM node
var map = new nokia.maps.map.Display(mapContainer, {
    // Initial center and zoom level of the map
    center: [18.975, 72.825833],
    zoomLevel: 10,
    components: [ infoBubbles,      
        new nokia.maps.map.component.Behavior()
    ]
});

var searchManager = nokia.places.search.manager,
    resultSet;


var defaultHandler = function (evt) {
    console.log(evt.target);
    infoBubbles.openBubble('<h3>' +evt.target.title + '</h3>' + evt.target.vicinity + '<br/>'
    + '<a onclick="getPhoneNumber(\'' + evt.target.placeId +'\')" >Get Phone</a>' ,evt.target.position)
};      

var myData;
var searchCat;  
var maxDistance = 0;


var getPhoneNumber = function (placeId){

    nokia.places.manager.getPlaceData({
            placeId: placeId,
            basicInfo: true,
            onComplete: function (data, status) {
                if ( data.contacts.phone === undefined ){
                    alert ("Unknown");
                } else {
                    alert(data.contacts.phone[0].value);
                }
            }
        });
};

// Function for receiving search results from places search and process them
var processResults = function (data, requestStatus, requestId) {
    var i, len, locations, marker;

    myData = data;

    if (requestStatus == "OK") {
        // The function findPlaces() and reverseGeoCode() of  return results in slightly different formats
        locations = data.results ? data.results.items : [data.location];
        // We check that at least one location has been found
        if (locations.length > 0) {
            // Remove results from previous search from the map
            if (resultSet) map.objects.remove(resultSet);
            // Convert all found locations into a set of markers
            resultSet = new nokia.maps.map.Container();
            for (i = 0, len = locations.length; i < len; i++) {
                marker = new nokia.maps.map.StandardMarker(locations[i].position, { text: i+1 });
                marker.title = locations[i].title;
                marker.position = locations[i].position;
                marker.vicinity = locations[i].vicinity;
                marker.placeId = locations[i].placeId;
                marker.addListener("click", defaultHandler);
                resultSet.objects.add(marker);
                if (locations[i].distance > maxDistance){
                    maxDistance = locations[i].distance;
                }
            }
            // Next we add the marker(s) to the map's object collection so they will be rendered onto the map
            map.objects.add(resultSet);
            // We zoom the map to a view that encapsulates all the markers into map's viewport
            map.zoomTo(resultSet.getBoundingBox(), false);


            progressUiElt.innerHTML = locations.length  + " places found in the '" + searchCat + "' category within " + maxDistance + "m of "+ data.search.location.address.city ;
        } else { 
            alert("Your search produced no results!");
        }
    } else {
        alert("The search request failed");
    }
};



// Binding of DOM elements to several variables so we can install event handlers.
var progressUiElt = document.getElementById("progress");


searchByCategory = function(searchCenter   , category){
// Make a place search request
searchCat = category;
progressUiElt.innerHTML = "Looking for places in the '" + category + "' category...'";
searchManager.findPlacesByCategory({
    category: category,
    onComplete: processResults,
    searchCenter: searchCenter,
    limit: 100,
});
}
// Search for Hotels in Mumbai
searchByCategory( new nokia.maps.geo.Coordinate(18.975, 72.825833), "hotel" );

        </script>
    </body>
</html>

The data from the JavaScript API can be seen below:

Hotels in Mumbai

Regarding phone numbers, please bear in mind the Restrictions from the Terms and Conditions

(ii) You will not copy, translate, modify, or create a derivative work (including creating or contributing to a database) of, or publicly display any Content or any part thereof except as explicitly permitted under this Agreement. For example, the following are prohibited: ... (iii) creating mailing lists or telemarketing lists based on the Content; or (iv) exporting, writing, or saving the Content to a third party's location-based platform or service ;

Jason Fox
  • 5,115
  • 1
  • 15
  • 34