Instagram图片到你周围1公里半径的谷歌地图

时间:2014-03-16 11:09:12

标签: javascript api google-maps instagram

我想知道是否有可能将Instagram照片发送到使用API​​的Google地图。到目前为止,我已经使谷歌地图工作,它显示了我当前的位置,以及我周围1公里的半径。

我想要做的就是在我周围展示一定数量的Instagram照片,由每个人拍摄。

但到目前为止,我不知道在哪里或如何开始,如果它甚至可能。

我的谷歌地图的代码是:

    </script>
        <script type="text/javascript">
        var map;
        var service;
        var marker;
        var pos;
        var infowindow;

        function initialize() {

            var mapOptions = {
                zoom: 14
            };

            map =   new google.maps.Map(document.getElementById('map-canvas'),
                    mapOptions);

            //HTML5 geolocation
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(function (position) {
                    pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);


                    infowindow = new google.maps.InfoWindow({
                        map: map,
                        position: pos,
                        content: 'This is your current position!'
                    });

                        var circle = new google.maps.Circle({
                            map: map,
                            position: pos,
                            radius: 1000,    // 1km in metres
                            fillColor: '#6D86D1'
                        });
                        circle.bindTo('center', infowindow, 'position');

                    map.setCenter(pos);

                    infowindow = new google.maps.InfoWindow();
                    var service = new google.maps.places.PlacesService(map);
                    service.nearbySearch(request, callback);

                },

                    function () {
                        handleNoGeolocation(true);
                    });
            } else {
                handleNoGeolocation(false);
            }

            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);
                });

            }
        }
        google.maps.event.addDomListener(window, 'load', initialize);


    </script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

您必须使用媒体/搜索API来获取某个位置(lat/lng)和distance周围的照片:

https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351&distance=1000&access_token=ACCESS-TOKEN

以下是在Google地图上获取任意半径范围内的Instagram照片的实现: http://www.gramfeed.com/instagram/map