search
HomeWeChat AppletMini Program DevelopmentWeChat Mini Program Example: How to call Tencent Map to obtain jsonp data

This article brings you an example of WeChat applet: how to call Tencent Map to obtain jsonp data. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Use the built-in js of the WeChat applet to call the Tencent map api to obtain the location information, and the returned jsonp data
The analysis method is as follows:

  //根据经纬度对象获取位置详细信息
  getLocationInfo: function (location){
    let _this = this;    
    var data = {
      location: location.latitude + "," + location.longitude,      
      /*腾讯地图key*/
      key: "************************",
      get_poi: 0  
    };    var url = 'https://apis.map.qq.com/ws/geocoder/v1/?';
    wx.request({
      type: "get",
      dataType: 'jsonp',
      data: data,
      jsonp: "callback",
      jsonpCallback: "QQmap",
      url: url,
      success: function(res) {
        let data = res.data;    #此处data是格式化的字符串,并不是对象        var json = JSON.parse(data);    #把data转换成对象        if (json.status == 0) {
          #此处写业务逻辑
        }
      },
      fail: function(res) {
        console.log(res)
      },
    })
  }

Related recommendations:

How to call API in WeChat applet to implement data request

How to pass parameters and receive data in WeChat applet

The above is the detailed content of WeChat Mini Program Example: How to call Tencent Map to obtain jsonp data. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version