I am working on an e-commerce toy project
Can play HTML JAVASCRIPT PHP
Can’t play 6
Originally I wanted to download a js framework to allow users to choose city addresses and so on, but then I felt it was too old
Now I want to solve a problem of how to realize the address positioning in HTML of mobile phones such as Taobao Ele.me Word-of-mouth. It is the first time I have thought about the need to implement this function after half a year of playing code. I don’t know how to start, please give me some advice.
lz is a poor primary school student. Please recommend public free APIs and frameworks. Thank you
I am working on an e-commerce toy project
Can play HTML JAVASCRIPT PHP
Can’t play 6
Originally I wanted to download a js framework to allow users to choose city addresses and so on, but then I felt it was too old
Now I want to solve a problem of how to realize the address positioning in HTML of mobile phones such as Taobao Ele.me Word-of-mouth. It is the first time I have thought about the need to implement this function after half a year of playing code. I don’t know how to start, please give me some advice.
lz is a poor primary school student. Please recommend public free APIs and frameworks. Thank you
Amap and Baidu Map both provide Javascript API, apply for it and then integrate it
For a simple one, you can check the location through the visitor's IP address. For a slightly more complicated one, you can get the location by obtaining the geographical location permission
<code>function getLocation(){ var options={ enableHighAccuracy:true, maximumAge:1000 } if(navigator.geolocation){ //浏览器支持geolocation navigator.geolocation.getCurrentPosition(onSuccess,onError,options); }else{ //浏览器不支持geolocation } } //成功时 function onSuccess(position){ //返回用户位置 //经度 var longitude =position.coords.longitude; //纬度 var latitude = position.coords.latitude; //得到经纬度就可以去通过百度or高德地图api获取城市地址 } //失败时 function onError(error){ switch(error.code){ case 1: alert("位置服务被拒绝"); break; case 2: alert("暂时获取不到位置信息"); break; case 3: alert("获取信息超时"); break; case 4: alert("未知错误"); break; } } window.onload=getLocation;</code>