MCPcopy Create free account
hub / github.com/bailicangdu/node-elm / geocoder

Method geocoder

prototype/addressComponent.js:145–174  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

143 }
144 //通过ip地址获取精确位置
145 async geocoder(req){
146 try{
147 const address = await this.guessPosition(req);
148 const params = {
149 key: this.tencentkey,
150 location: address.lat + ',' + address.lng
151 };
152 let res = await this.fetch('http://apis.map.qq.com/ws/geocoder/v1/', params);
153 if (res.status != 0) {
154 params.key = this.tencentkey2;
155 res = await this.fetch('http://apis.map.qq.com/ws/geocoder/v1/', params);
156 }
157 if (res.status != 0) {
158 params.key = this.tencentkey3;
159 res = await this.fetch('http://apis.map.qq.com/ws/geocoder/v1/', params);
160 }
161 if (res.status != 0) {
162 params.key = this.tencentkey4;
163 res = await this.fetch('http://apis.map.qq.com/ws/geocoder/v1/', params);
164 }
165 if (res.status == 0) {
166 return res
167 }else{
168 throw new Error('获取具体位置信息失败');
169 }
170 }catch(err){
171 console.log('geocoder获取定位失败', err);
172 throw new Error(err);
173 }
174 }
175 //通过geohash获取精确位置
176 async getpois(lat, lng){
177 try{

Callers 1

getExactAddressMethod · 0.80

Calls 2

guessPositionMethod · 0.95
fetchMethod · 0.80

Tested by

no test coverage detected