JQuery obtains latitude and longitude through the address demo, jquery latitude and longitude
Before getting started, you must first log on to the Baidu map API console to apply for a key ak.
1. login Baidu map open platform http://lbsyun.baidu.com
Register an account and complete the information. Click "API console" in the upper-right corner of the website and click "create application.
Application Type: "server", IP whitelist: 0.0.0.0/0
Click Submit. An access application (AK) is generated ).
2. Compile the interface.
<! DOCTYPE html> <Br> point: <input type = "text" name = "point" id = "point" style = "width: 30% "readonly> <button type =" button "id =" open "> getPoint </button> </body> 3. Core Methods
<Script type = "text/javascript"> document. getElementById ('open '). onclick = function () {var addressStr = $ ("# address "). val (); if (addressStr! = "") {$. Ajax ({url: "http://api.map.baidu.com/geocoder/v2/", data: {"address": addressStr, "output": "json", "ak": "ak you just applied "}, type: "post", dataType: 'jsonp', success: function (data) {var lng = data. result. location. lng; var lat = data. result. location. lat; $ ("# point "). val (lng + "," + lat) ;}}) ;}else {alert ("addres is not null! ") ;}}</Script>
4. effect display:
If no address is entered, the following message is displayed: