Code Note: Create a map with the high-D map API and get the current address latitude and longitude

Source: Internet
Author: User

Creating API maps with DOT markers
<Scriptsrc= "http://webapi.amap.com/maps?v=1.4.1&key=bcf87f3263f98cc37309298bca20c622"></Script><Scripttype= "Text/javascript">    //Instantiating point Markers functionAddmarker () {marker= Newamap.marker ({icon:"Http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", Position: [116.41, 39.91]        });    Marker.setmap (map); } varMap= NewAmap.map ('Container', {resizeenable:true, center: [116.40, 39.91], zoom: -    }); Addmarker ();</Script>
Get current latitude and longitude based on browser location
<DivID= "Container_display"></Div><Scriptsrc= "https://webapi.amap.com/maps?v=1.4.1&key=bcf87f3263f98cc37309298bca20c622"></Script><Script>functionLoadingcurrentposition (callback) {document.getElementById ('Container_display'). InnerHTML= "'; //load map, invoke browser location serviceMap= NewAmap.map ('Container_display', {resizeenable:true    }); Map.plugin ('amap.geolocation', function() {geolocation= Newamap.geolocation ({enablehighaccuracy:true,//whether to use high precision positioning, default: TrueTimeout:10000,          //stop positioning after more than 10 seconds, default: InfinityButtonoffset:NewAmap.pixel (Ten,  -),//The offset of the position button and the set docking position, default: Pixel (Ten)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: falsebuttonposition:'RB'        });        Map.addcontrol (geolocation);        Geolocation.getcurrentposition (); AMap.event.addListener (geolocation,' Complete', oncomplete);//Back to location informationAMap.event.addListener (geolocation,'Error', OnError); //return location error message    }); //Resolve positioning Results    functionOnComplete (data) {varGetlngdata=Data.position.getLng (); varGetlatdata=Data.position.getLat (); if(callback) {callback (getlngdata,getlatdata);//passing longitude and latitude in callback parameters        }    }    //Resolving positional error messages    functionOnError (data) {alert ('failed to locate'); }}$(function(){    varGETLNG= "'; //Deposit Longitude    varGetlat= "'; //Storage Latitude    //default loading automatically gets the current person's location onceLoadingcurrentposition (function(lngdata,latdata) {getlng=Lngdata; Getlat=Latdata;    }); $(". GetCurrentPosition"). On ('Click',function() {loadingcurrentposition (function(lngdata,latdata) {getlng=Lngdata; Getlat=Latdata;    }); });})</Script>

German map get current latitude and longitude API based on browser location address: http://lbs.amap.com/api/javascript-api/example/location/browser-location
German Open platform: HTTP://LBS.AMAP.COM/API

Code Note: Create a map with the high-D map API and get the current address latitude and longitude

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.