Baidu map IP acquires location. The interface has returned success, but a cross-domain error has been reported.

call Baidu Map ip to obtain the location API, and the data has been returned successfully, but a cross-domain error has been reported, resulting in the callback method unable to be executed. Ask for advice
clipboard.png

clipboard.png

Failed to load https://api.map.baidu.com/loc.: No "Access-Control-Allow-Origin" header is present on the requested resource. Origin" https://127.0.0.1:8087" is therefore not allowed access.

this.$http.get(`https://api.map.baidu.com/location/ip?ak=${AK}&coor=bd09l`).then(res => {
      console.log(res);
      this.x = res.location;
      this.y = res.latitude;
      let mk = new BMap.Marker(res.point);
      map.addOverlay(mk);
      map.panTo(res.point);
    })

  1. from the official example, it is supported to add the callback parameter to jsonp form.
  2. backend request.
Menu