Baidu Map API positioning the current location

Source: Internet
Author: User

<!DOCTYPE HTML><HTMLLang= "en"> <Head>  <MetaCharSet= "UTF-8">  <Metaname= "Generator"content= "EditPlus?">  <Metaname= "Author"content="">  <Metaname= "Keywords"content="">  <Metaname= "Description"content="">  <title>Baidu Map</title>  <Scripttype= "Text/javascript"src= "Http://api.map.baidu.com/api?ak=PlhFWpA02aoURjAOpnWcRGqw7AI8EEyO&v=2.0&services=false"></Script>  </Head> <Body>    <style>Body, HTML{width:100%;Height:100%;margin:0;font-family:"Microsoft Jas Black";}#allmap{Height:500px;width:100%;}    </style>    <DivID= "Allmap"></Div>    <Scripttype= "Text/javascript">        $(function(){            varMap= NewBmap.map ("Allmap"); var Point= NewBmap.point (116.501573, 39.900877); Map.centerandzoom (Point, -)            //anchored Objects            varGEOC= NewBmap.geocoder (); vargeolocation= Newbmap.geolocation (); Geolocation.getcurrentposition (function(r) {if( This. GetStatus ()==bmap_status_success) {                    varMk= NewBmap.marker (R.point);                    Map.addoverlay (MK);                    Map.panto (R.point); //$ ("#start_point"). Val (r.point.lng+ ', ' +r.point.lat);Alert ("Current position longitude is:"+R.POINT.LNG+"Latitude is:"+R.point.lat);                SetLocation (R.point); }Else {                    $("#start"). attr ("placeholder","Please enter your current location") Alert ('Unable to navigate to your current location, navigation failed, please enter your current location manually! '+ This. GetStatus ()); }},{enablehighaccuracy:true}); //get the location of the function            functionsetlocation (point) {geoc.getlocation (point),function(RS) {varAddcomp=rs.addresscomponents; varresult=addcomp.province+addcomp.city+addcomp.district+Addcomp.street+Addcomp.streetnumber; //$ ("#start"). Val (result);                    //$ ("#start_location"). Val (result);Alert ("The current location is:"+result);            });    }        }); </Script> </Body></HTML>

Baidu Map API positioning the current location

Related Article

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.