名未闻 2018-11-26 07:11
浏览 1484

谷歌地图使用周边搜索功能,api用的国内的,功能无法实现,求大神指点!

<!DOCTYPE html>
<html>
<head>
    <title>Place Searches</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>

        #map {
            height: 100%;
        }

        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>

    <script async defer src="http://ditu.google.cn/maps/api/js?key=AIzaSyBGLAD67RAs5eK5kwQp7BE5MmexoGhVdn0&sensor=TRUE&libraries=places&callback=initMaps&libraries=places"></script>

    <script>
        var map;
        var infowindow;
        function initMap() {
            var pyrmont = {lat:43.65362965616052, lng:-79.38284097724608};
            map = new google.maps.Map(document.getElementById('map'), {
                center: pyrmont,
                zoom: 15
            });

            infowindow = new google.maps.InfoWindow();
            var service = new google.maps.places.PlacesService(map);
                rvice.nearbySearch({
                location: pyrmont,
                radius: 500,
                type: ['school']
            }, callback);
        }


        function callback(results, status) {
            if (status === google.maps.places.PlacesServiceStatus.OK) {
                for (var i = 0; i < results.length; i++) {
                    createMarker(results[i]);
                }
            }
        }

        function createMarker(place) {
            var placeLoc = place.geometry.location;
            var marker = new google.maps.Marker({
                map: map,
                position: place.geometry.location
            });

            google.maps.event.addListener(marker, 'click', function() {
                infowindow.setContent(place.name);
                infowindow.open(map, this);
            });
        }
    </script>
</head>
<body onload="initMap()">
<div id="map"></div>

</body>
</html> 

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题