Coder Social home page Coder Social logo

wxapp-jsapi's Introduction

百度地图微信小程序JavaScript API v1.0

相关链接:
百度地图开放平台
百度地图微信小程序JSAPI服务
##更新日志## 2017.01.11:发布v1.0版本,支持search、suggestion、regeocoding和weather四种接口。
2017.02.15:修复location参数无效的bug ##概述 百度地图微信小程序JavaScript API(下文简称小程序JSAPI)的作用是对百度地图Web服务API中的部分接口按照微信小程序的规范进行了前端JS封装,方便了微信小程序开发者的调用。部分接口对返回的POI等数据按照微信小程序的数据格式进行了处理,可直接用于小程序的map中。目前开放的小程序JSAPI接口和调用的WebAPI接口对应关系为:

小程序JSAPI Web服务API
search Place API的周边检索部分
suggestion Place Suggestion API
regeocoding Geocoding API的逆地址解析部分
weather 天气 API

##目录结构

demo ------------- 小程序JSAPI完整DEMO
src --------------- 小程序JSAPI源码

##类参考

BMapWX

此类是小程序JSAPI的核心类。

**构造函数:**

构造函数 描述
BMapWX(ak: string) 创建 BMapWX对象时,必须要传入ak

**方法:**

方法名 返回值 描述
search(searchParam: Object) none 进行search检索,检索周边POI信息
suggestion(suggestionParam: Object) none 进行suggestion检索,根据内容进行模糊检索匹配,输入补全
regeocoding(regeocodingParam: Object) none 进行regeocoding检索,根据经纬度获得对应的地理描述信息
weather(weatherParam: Object) none 进行weather检索,查询指定地点的天气信息

**参数:**

***searchParam: Object***
search检索参数对象结构
属性名 类型 是否必须 描述
location string 经纬度例如:39.915,116.404 默认值为当前定位点
iconPath string 小程序marker图标
iconTapPath string 小程序点击后图标
width number marker宽,默认为图片宽度
height number marker高,默认为图片高度
alpha number marker透明度,默认为1
query string 检索关键字,默认为生活服务、美食、酒店
success Function(searchSuccess) 检索成功后回调回调函数
fail Function(searchFail) 检索失败后回调函数

其他参数和Place API请求参数一致。

***searchSuccess: Object***
search检索成功回调函数的参数
属性名 类型 是否必须 描述
wxMarkerData Array 小程序格式的marker对象数组,参考微信文档
originalData Object Place API请求返回全部原始数据
***searchFail: Object***
search检索失败回调函数的参数
属性名 类型 是否必须 描述
errMsg string 错误信息
statusCode number 错误状态码
***suggestionParam: Object***
suggestion检索参数对象结构
属性名 类型 是否必须 描述
success Function(suggestionSuccess) 检索成功后回调函数
fail Function(suggestionFail) 检索失败后回调函数

其他参数和Place Suggestion API请求参数一致。

***suggestionSuccess: Object***
suggestion检索成功回调函数的参数
属性名 类型 是否必须 描述
originalData Object Place Suggestion API请求返回全部原始数据
***suggestionFail: Object***
suggestion检索失败回调函数的参数
属性名 类型 是否必须 描述
errMsg string 错误信息
statusCode number 错误状态码
***suggestionParam: Object***
regeocoding检索参数对象结构
属性名 类型 是否必须 描述
location string 要解析的经纬度例如:39.915,116.404 默认值为当前定位点
iconPath string 小程序marker图标
iconTapPath string 小程序点击后图标
width number marker宽,默认为图片宽度
height number marker高,默认为图片高度
alpha number marker透明度,默认为1
success Function(regeocodingSuccess) 检索成功后回调函数
fail Function(regeocodingFail) 检索失败后回调函数

其他参数和Geocoding请求参数一致。

***regeocodingSuccess: Object***
regeocoding检索成功回调函数的参数
属性名 类型 是否必须 描述
wxMarkerData Array 小程序格式的marker对象数组,参考微信文档
originalData Object Geocoding API请求返回全部原始数据
***regeocodingFail: Object***
regeocoding检索失败回调函数的参数
属性名 类型 是否必须 描述
errMsg string 错误信息
statusCode number 错误状态码
***weatherParam: Object***
weather检索参数对象结构
属性名 类型 是否必须 描述
location string 要解析的纬经度例如:116.43,40.75 默认值为当前定位点
success Function(weatherSuccess) 检索成功后回调函数
fail Function(weatherFail) 检索失败后回调函数

其他参数和天气接口请求参数一致。

***weatherSuccess: Object***
weather检索成功回调函数的参数
属性名 类型 是否必须 描述
currentWeather Obejct 当前天气的重要信息
originalData Object 天气接口请求返回全部原始数据
***weatherFail: Object***
weather检索失败回调函数的参数
属性名 类型 是否必须 描述
errMsg string 错误信息
statusCode number 错误状态码
***currentWeather: Object***
weather检索结果中的当前重要信息
属性名 类型 是否必须 描述
currentCity string 当前城市
pm25 string PM2.5浓度
date string 日期
temperature string 温度
weatherDesc string 天气描述
wind string 风力

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.