我的反向地址解析现在可以使用了,现在可以发布地址了,但是我无法将其发布到我的API中

时间:2019-07-15 09:54:33

标签: angular7 reverse-geocoding

我只是想使用我的API发布当前地址

if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(position => {
    // x.value = "" + position.coords.longitude;
    // y.value = "" + position.coords.latitude;


    this.locations.push({ lng: position.coords.longitude, lat: position.coords.latitude, time: local.value, picture: picture.value,  publicIp : publicIp.value, privateIp: privateIp.value });
    console.log(this.locations);

    console.log(local.value);

     $.get( "https://maps.googleapis.com/maps/api/geocode/json?latlng="+position.coords.latitude+","+position.coords.longitude+"&key=AIzaSyCCM4Cq46sTxLGAqRB1L9BmjkVuoLq05Vw", function(data) {
                console.log(data);

                x.value = data.results[3].address_components[0].long_name+",";
                x.value += data.results[3].address_components[1].long_name+",";
                x.value += data.results[3].address_components[2].long_name+",";
                x.value += data.results[3].address_components[3].long_name+",";
                x.value += data.results[3].address_components[4].long_name;

              })

    this.JsonFileService.setLogIn([{

      "SourceId" : userId,
      "accountId" : userId,
      "latitude" : position.coords.latitude,
      "longitude" : position.coords.longitude,
      "privateIp" : privateIp.value,  
      "publicIp" : publicIp.value,     
      "dateTime" : local.value,
      "image" : picture.value

    }]).subscribe(data => {
      console.log(data);

  });


} else {
  err.innerHTML = "Geolocation is not supported by this browser.";
}

}

未找到错误。如果我使用输入标签并放入ID,则可以在尝试将其用在angular上时获取地址,这只是显示长纬度

0 个答案:

没有答案