2016-12-08 6 views
-1

を使用してGoogleマップでFoursquareのAPIを使用して、いくつかは私がここで私はGoogleマップでFoursquareのAPIを実装しようとしているJavaScriptの

function createMarker(location){ 
    var marker = new google.maps.Marker({ 
    map: map, 
    position: location.latlng, 
    title: location.name, 
    animation: google.maps.Animation.DROP 
    }); 

    location.marker = marker; 

    getVenueDetails(location, function(windowContent){ 
    infoWindow.setContent(windowContent); 
    infoWindows.push(infoWindow); 
    }); 
google.maps.event.addListener(marker, 'click', function() { 
    getVenueDetails(location, function(windowContent){ 
    infoWindow.setContent(windowContent); 
    infoWindow.open(map, self); 
    }); 
}); 
    } 
    var baseUrl = 'https://api.foursquare.com/v2/venues/search?', 
    clientId = '*********************************************', 
    clientSecret = '*******************************************'; 

function getVenueDetails(location, infoWindowCallback) { 
foursquareUrl = baseUrl + '&client_id=' + clientId + '&client_secret=' + clientSecret + '&v=20161207&query=' + Model[location].id + '&ll=11.93,79.82'; 
$.getJSON(foursquareUrl) 
    .done(function(data){ 
    var currentVenue = data.response.venues[0]; 
    var placeName = currentVenue.name; 
    var placeAddress = currentVenue.address.formattedAddress; 
    var placePhonenos = (currentVenue.contact.formattedPhone === undefined)? 'None': currentVenue.contact.formattedPhone; 
    windowContent = '<div id="iw_container"><p><strong>Name: </strong>' + placeName+ '</p>' + 
       '<p><strong>Address: </strong> ' + placeAddress + '</p>' + 
       '<p><strong>Phone: </strong>' + placePhonenos + '</p></div>'; 
    infoWindowCallback(windowContent); 
    }).fail(function(error){ 
    infoWindow.setContent('Fail to connect to Foursquare: ' + error); 
    } 
); 
    } 

は私のレポmapです....来続けるエラーを整理することができます... アムモデル[場所] .ID ..私が手に主にあるAPIセクションでエラーを取得中にエラーが定義されていない「ID」は、...すべてのヘルプは

答えて

0

...高く評価され、私は定義されてidが表示されませんあなたのModelクラスで。また、緯度/経度ではなく、Foursquareの検索queryパラメータに会場名を渡す必要があります。 Model[location].idModel[name]に変更する必要があります。

このラインを交換してみてください:

これにより
foursquareUrl = baseUrl + '&client_id=' + clientId + '&client_secret=' + clientSecret + '&v=20161207&query=' + Model[location].id + '&ll=11.93,79.82'; 

foursquareUrl = baseUrl + '&client_id=' + clientId + '&client_secret=' + clientSecret + '&v=20161207&query=' + Model[name] + '&ll=11.93,79.82'; 
関連する問題