//通过网络获取手机坐标GPS var lastFix = getLocation(‘net’, true, 10); var loc = global(‘%LOCN’).split(",");
//手机坐标GPS转换为高德坐标 var loc0 = Number(loc[1]).toFixed(6); var loc1 = Number(loc[0]).toFixed(6); var convertUrl = "http://restapi.amap.com/v3/assistant/coordinate/convert?locations=" + loc0 + "," + loc1 + "&coordsys=gps&output=json&key="+amapkey; var amapLoc = JSON.parse(gethttp(convertUrl)).locations.split(",");
//根据坐标获取当前行政区域信息 var loc0 = Number(amapLoc[0]).toFixed(6); var loc1 = Number(amapLoc[1]).toFixed(6); var regeoUrl = "http://restapi.amap.com/v3/geocode/regeo?output=json&location=" + loc0 + "," + loc1 + "&key="+amapkey+"&radius=100&extensions=all" var result = JSON.parse(gethttp(regeoUrl)); var addressComponent = result.regeocode.addressComponent; var contry = addressComponent.contry; var province = addressComponent.province; var city = addressComponent.city; var district = addressComponent.district; var townshipy = addressComponent.township; var name = result.regeocode.pois[0].name; var address = result.regeocode.pois[0].address;
//flash(townshipy + name);//提示街道和小区名
//获取小时天气数据 var loc0 = Number(loc[1]).toFixed(4); var loc1 = Number(loc[0]).toFixed(4);
//解析天气数据 var result = JSON.parse(gethttp(weatherUrl)); var hourly_description = result.result.hourly.description; var forecast_keypoint = result.result.forecast_keypoint; var wind = result.result.hourly.wind[0].speed + " km/h"; var humidity = result.result.hourly.humidity[0].value + " %"; var pmmm = result.result.hourly.pm25[0].value; var skycon = result.result.hourly.skycon; var skycon0 = skycon[0].value; var temperature = result.result.hourly.temperature; var temperature0 = temperature[0].value + " ℃"; var pm25 = result.result.hourly.pm25; var pm250 = pm25[0].value;