Mobile phone to get the user's detailed geographical location (Gold Map API)

Source: Internet
Author: User

Project development needs to get user detailed geo-location information, using the Gold Map API interface

1, sign up for the developer account of the Gold Map developer Key 2, page call

1 <script type= "Text/javascript" src= "http://webapi.amap.com/maps?v=1.4.3&key= the key value you requested" > </script>

3, sample code
1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4     <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5     <Metaname= "Viewport"content= "initial-scale=1.0, User-scalable=no">6     <title>Get a location</title>7     <styletype= "Text/css">#iCenter{width:300px;Height:280px;Border:1px #000 Solid;margin:20px Auto;}</style>8     <Scripttype= "Text/javascript"src= "http://webapi.amap.com/maps?v=1.4.3&key=3df877a70685dac5ecb3afa375d4c305"></Script>9 </Head>Ten <Body> One  A <DivID= "Icenter"></Div> -  - <Scripttype= "Text/javascript"> the     varMapobj= NewAmap.map ('Icenter'); - Mapobj.plugin ('amap.geolocation', function () { - geolocation= Newamap.geolocation ({ - enablehighaccuracy:true, //whether to use high precision positioning, default: True + Timeout:10000,           //stop positioning after more than 10 seconds, default: Infinity - Maximumage:0,            //Locating result Cache 0 MS, default: 0 + Convert:true,            //Auto Offset coordinates, offset by the gold coordinates, default: True A Showbutton:true,         //Show Positioning button, default: True at buttonposition:'LB',     //Positioning button Docking position, default: ' LB ', lower left corner - Buttonoffset:NewAmap.pixel (Ten,  -), //The offset of the position button and the set docking position, default: Pixel (Ten) - Showmarker:true,         //show point markers in position to location after successful positioning, default: True - showcircle:true,         //The positioning accuracy range is represented by a circle after successful positioning, by default: True - pantolocation:true,      //location to locate after successful positioning as the Map center point, default: True - zoomtoaccuracy:true       //Adjust the map's field of view after successful positioning to make the location and accuracy range visible in the field of view, default: false in         }); - Mapobj.addcontrol (geolocation); to geolocation.getcurrentposition (); + AMap.event.addListener (geolocation,' Complete', OnComplete); //Back to location information - AMap.event.addListener (geolocation,'Error', OnError); //return location error message the     }); *  $     functionOnComplete (obj) {Panax Notoginseng         varRes= 'latitude and Longitude:' +obj.position+  -                 '\ n Accuracy range:' +obj.accuracy+  the                 'meter \ n The source of the location result:' +Obj.location_type+  +                 '\ n status information:' +Obj.info+  A                 '\ n Address:' +obj.formattedaddress+  the                 '\ n Address information:' +json.stringify (obj.addresscomponent,NULL, 4); + alert (res); -     } $  $     functionOnError (obj) { - Alert (Obj.info+ '--' +obj.message); - console.log (obj); the     } - </Script>Wuyi </Body> the </HTML>

Copy the code directly into the HTML file and view the specific information on the phone side

Mobile phone to get the user's detailed geographical location (Gold Map API)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.