Google地方信息仅请求特定的字段/详细信息

时间:2019-05-10 09:23:23

标签: javascript google-maps google-places-api

我正在为出租车公司进行当前的项目。我的问题是,每当我们向Google请求地址时,我们都会得到包含不需要的详细信息的回复。自从实行新的定价政策以来,我们的账单增长了200%。因此,通过限制返回的详细信息,我可以减少请求数量。抱歉,英语不是我的母语。该项目使用Meteor JS构建。我还使用jQuery地理编码和Places自动完成插件-V 1.7.0进行自动完成。通过修改插件,可以从Google添加您需要哪种数据?

到目前为止,我已经尝试添加特定的详细信息属性。   var默认值= {     范围:正确,     strictBounds:错误,     国家:null,     地图:假,     详细信息:['address_component','adr_address','alt_id','formatted_address','geometry','icon','id','name','permanently_closed','photo','place_id','plus_code' ,“范围”,“类型”,“ url”,“ utc_offset”,“附近”],     detailsAttribute:“名称”,     detailsS​​cope:null,     自动选择:是,     位置:错误, (详细信息以前设置为false) 我也曾尝试实现字段,但到目前为止还没有运气。

这是我目前正在使用的代码。


Template.add_order.events({

'click .new_callorder': function(){
    Meteor.call('dispCreateCall', Session.get('currentBnr'));
    console.log('luuakse uus korralduse pohi / kone', Session.get('currentBnr'));
},




'focus .fstart': function(e, t){
    var callid = $(e.currentTarget).attr('data-callid');
    var delay = (function(){
        var timer = 0;
        return function(callback, ms){
            clearTimeout (timer);
            timer = setTimeout(callback, ms);
        };
    })();
    $('#fstart-' +callid).keyup(function() {
        delay(function(){
        }, 5000 );
});
    $('#map').show();
    google.maps.event.trigger(gmaps.map, 'resize');

    $('#fstart-'+callid)
  .geocomplete({
      map: gmaps.map,
        types: ['geocode', 'establishment'],
      mapOptions: {
        zoom: 1,

      },
        componentRestrictions: {country: 'ee'},
      markerOptions: {
            label: 'a',
        draggable: true
      }})
  .bind("geocode:result", function(event, result){
        console.log('result on',result)
        $('#fstart-lat-'+callid).val(result.geometry.location.lat());
        $('#fstart-lng-'+callid).val(result.geometry.location.lng());
        console.log('lat',result.geometry.location.lat(),'lng',result.geometry.location.lng())
        $('#fstart-'+callid).val($('#fstart-'+callid).val())

})
    .bind("geocode:error", function(event, result){
        alert('Error: '+event+' / ' + result);
    })
    .bind("geocode:dragged", function(event, latLng){
        $('#fstart-lat-'+callid).val(latLng.lat());
        $('#fstart-lng-'+callid).val(latLng.lng());
      var map = gmaps.map;
      map.panTo(latLng);
      var geocoder = new google.maps.Geocoder();

      geocoder.geocode({'latLng': latLng }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          if (results[0]) {
                    var house = results[0].address_components[0].long_name;
            var road = results[0].address_components[1].long_name;
            var town = results[0].address_components[2].long_name;
            var county = results[0].address_components[3].long_name;
            var country = results[0].address_components[4].long_name;
            $('#fstart-'+callid).val(road + ' ' + house + ', ' + town+', '+county);
          }
        }
      });

    });


},



'focus .fend': function(e, t){
    $('#map').show();
    var callid = $(e.currentTarget).attr('data-callid');
    var startend = $(e.currentTarget).attr('data-startend');
    $('#fend-'+callid)
    .geocomplete({
        map: gmaps.map,
        types: ['geocode', 'establishment'],
      mapOptions: {
            zoom: 1,

      },

        componentRestrictions: {country: 'ee'},
      markerOptions: {
            label: 'b',
        draggable: true
      }})
  .bind("geocode:result", function(event, result){
        var cstart = new google.maps.LatLng($('#fstart-lat-'+callid).val(), $('#fstart-lng-'+callid).val());
        console.log('teekonnaarvutuse cstart',cstart);
        $('#fend-lat-'+callid).val(result.geometry.location.lat());
        $('#fend-lng-'+callid).val(result.geometry.location.lng());

        var distanceCalc = gmaps;
        distanceCalc.calculateDistances(cstart, $('#fstart-'+callid).val(),result.geometry.location,$('#fend-'+callid).val(),callid);


    });

},

当前,通过查找我国某所学校来获得此回复。

当前我们不需要,例如,国际电话号码,照片,用户评分,网站,格式化电话号码

0 个答案:

没有答案
相关问题