JavaScript's access to Baidu address parameter method

Source: Internet
Author: User

Native JavaScript is more convenient for DOM operations than jquery, especially when no ID or class is available, only with tag name.

HTML DOM Element Object Operation http://www.w3school.com.cn/jsref/dom_obj_all.asp

Baidu Open Platform: http://lbsyun.baidu.com/index.php?title=open/library&qq-pf-to=pcqq.group

#container{Font-size:12px; Margin: 5px 0; }</style><title>City List Display Example</title><script type= "Text/javascript" src= "http://api.map.baidu.com/api?v=1.4" ></script>< Script type= "Text/javascript" src= "Http://api.map.baidu.com/library/CityList/1.4/src/CityList_min.js" ></ Script>//New Map CreationvarMap =NewBmap.map ("Map_container"); Map. Centerandzoom (NewBmap.point (121.478125,31.229649), 12);varCityList =NewBmaplib.citylist ({container: ' Container ',Map:map}); CityList. getbusiness (' Zhongguancun ',function(JSON) {Console.Log(' Business Circle '); Console.Log(JSON);}); CityList. getsubarealist (131,function(JSON) {Console.Log(' City list '); Console.Log(JSON); }); CityList. AddEventListener (' Cityclick ',function(e) {Console.Log(e);});functiondisplaydate () {varAreaindex = 16; varb = document.getElementsByTagName (' select ') [2].Childnodes[areaindex]; varc = document.getElementsByTagName (' select ') [3].ChildNodes; varTXT = ";  for(I=1; i<c.length; i++)    {        if(i<c.length-1) {txt+ = ' (\ ' +c[i].value + ' \ ' + ', ' + ' \ ' +c[i].text+ ' \ ' + ', ' + ' \ ' +b.value+ ' \ ' + '), ' + ' <br> '; }Else{txt+ = ' (\ ' +c[i].value + ' \ ' + ', ' + ' \ ' +c[i].text+ ' \ ' + ', ' + ' \ ' +b.value+ ' \ ' + ') ' + ' <br> ';        }    }; varX=document.getelementbyid ("Demo"); X. innerhtml=txt;}</script>


<script type= "Text/javascript" src= "http://api.map.baidu.com/api?v=1.4" ></script><script type= " Text/javascript "src=" Http://api.map.baidu.com/library/CityList/1.4/src/CityList_min.js "></script>

<button type= "button" onclick= "Displaydate ()" >show</button>
<div id= "Demo" ></div></body>var citylist = new Bmaplib.citylist ({container: ' container ', map:map});
Citylist.getbusiness (' Zhongguancun ', function (JSON) {console.log (' Business Circle '); Console.log (JSON);});
Citylist.getsubarealist (131, function (JSON) {console.log (' city list ');    Console.log (JSON); });
Citylist.addeventlistener (' Cityclick ', function (e) {console.log (e);});

function Displaydate () {
var areaindex = 16;
var B = document.getelementsbytagname (' select ') [2].childnodes[areaindex];
var c = document.getelementsbytagname (' select ') [3].childnodes;
var txt = ';
for (I=1; i<c.length; i++) {if (i<c.length-1) {txt + = ' (\ ' +c[i].value + ' \ ' + '), ' + ' \ ' +c[i].tex        t+ ' + ' + ', ' + ' \ ' +b.value+ ' \ ' + '), ' + ' <br> '; }else{
TXT + = ' (\ ' +c[i].value + ' \ ' + ', ' + ' \ ' +c[i].text+ ' \ ' + ', ' + ' \ ' +b.value+ ' \ ' + ') ' + ' <br> ';        }    };          var X=document.getelementbyid ("demo"); X.innerhtml=txt;
}


</script>

JavaScript's access to Baidu address parameter method

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.