google-maps - PlacesService和html节点的需要

标签 google-maps licensing google-places-api

<html>
    <head>
        <script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places&language=pt-PT" type="text/javascript"></script>
        <script type="text/javascript">
            function initialize() {
                var request = {
                    placeId: 'ChIJO_PkYRozGQ0R0DaQ5L3rAAQ'
                };

                service = new google.maps.places.PlacesService(document.getElementById('places'));
                service.getDetails(request, callback);

                function callback(place, status) {
                    if (status == google.maps.places.PlacesServiceStatus.OK) {
                        console.log(place);
                    }
                }
            }
            google.maps.event.addDomListener(window, 'load', initialize);
        </script>
    </head>

    <body>  <div id="places"></div> </body>

</html>

我的代码运行良好,但我不知道为什么需要使用

PlacesService(document.getElementById('some id')); 

如果我只使用 PlacesService(); 我会收到错误。 html_attributions 为无:html_attributions: Array[0]length: 0

那么,我的代码没问题吗,或者我应该做什么?

http://jsfiddle.net/c6p14g4d/

最佳答案

(如果 6 个月后你还没有弄清楚)你的代码将会工作并且 should adhere to Google's policies surrounding the PlacesService .

根据我的理解,“归因”是将信息来源归因于特定合作伙伴的某种信息,例如来自 Yelp 的评论(我不知道他们是否与 Yelp 合作,但这就是想法) 。显然,合作伙伴希望信息的最终消费者知道是谁提供的。

这个想法是,当您使用 PlacesService 执行搜索时,如果有附加 map ,它将自动呈现“属性”。因此,如果您没有 map ,库将尝试将属性呈现到 html 节点中。隐藏该节点(或 map )是违反政策的。

需要注意的是,在使用该库时,html_attributions 数组可能并不总是为空,但只要您在 DOM 中提供一个可见节点,没问题,因为库会自动用属性填充节点(如果属性存在)。

关于google-maps - PlacesService和html节点的需要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27990005/

相关文章:

mysql - facebook、twitter 等网站需要 mysql 许可证吗

javascript - Google Places JavaScript 自动完成 : can I remove the country from the place name?

ios - 无法获取地点 - REQUEST_DENIED

android - 检查 GPS 纬度/经度点是否位于 Google map 中的道路上

c++ - 通过C++访问MySQL

java - 为什么 Google map Gocode 在我的 Android 设备上(而不是在浏览器上)返回零结果

matlab - Deploytool for MATLAB R2013b 不起作用,发生了什么变化?

android - 如何使用适用于 Android 的谷歌地图获取特化的医院详细信息?

android - 如何在 Android 上显示自定义 map

python - 如何让 googlemaps python 库检测 SSL 证书?