我嘗試了Google地方API,它正在爲「placeted_phone_number」或「international_phone_number」地點返回電話。如何使用Google place API或任何其他更好的API獲取某個地方的電話號碼
但它並沒有返回所有地方(僅限100個地方中的1個)。但是,目前我想要獲得每個地方的電話號碼(例如: - 酒店)。
我會將緯度和經度信息發送給API,它需要返回最近的酒店地址和電話號碼。
請爲此建議我更好的API。
我嘗試了Google地方API,它正在爲「placeted_phone_number」或「international_phone_number」地點返回電話。如何使用Google place API或任何其他更好的API獲取某個地方的電話號碼
但它並沒有返回所有地方(僅限100個地方中的1個)。但是,目前我想要獲得每個地方的電話號碼(例如: - 酒店)。
我會將緯度和經度信息發送給API,它需要返回最近的酒店地址和電話號碼。
請爲此建議我更好的API。
您可以從任何Places API接收的數據質量(例如電話號碼)完全取決於備份該API的數據的質量。這將因供應商不同而不同,覆蓋範圍因國家,城市而異等等。
這裏最好的辦法是運行某種「選美比賽」,以瞭解哪家供應商擁有與您相關的最佳數據集。
要獲得使用例如諾基亞的RESTful Places API的一個地方的電話號碼,是一個兩個階段的過程:
同樣不是所有的地方都會包含電話信息。現在,您可以將第一個請求的響應鏈接到收到的placeIds,並將電話號碼放在屏幕上。
另一種方法是使用現有的JavaScript API封裝如下圖所示的代碼來顯示信息,你需要自己app id and token得到它從JavaScript API的工作
<!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>
數據可以看到下面:
關於電話號碼,請記住從Terms and Conditions
承受的限制(ii)您將不能複製,翻譯,修改或創建衍生作品 (包括創建或有助於數據庫)的,或公開 顯示任何內容或其任何部分,除非明確允許 下這項協議。例如,以下是禁止的: ... (iii)根據內容創建郵件列表或電話營銷列表;或(iv)將內容導出,寫入或保存到第三方的基於位置的平臺或服務;
@Janon Thanks man –
如果數據可用,Places API會返回地點的電話號碼。不幸的是,在一些地區,地方的數據可能不完整。如果您知道這些電話號碼或更多關於這些地方的信息,可以使用Google地圖製作工具添加:http://www.google.com/mapmaker –