码迷,mamicode.com
首页 > 编程语言 > 详细

javascript 之获取 百度地址参数方法

时间:2017-03-17 15:08:23      阅读:475      评论:0      收藏:0      [点我收藏+]

标签:lib   title   开放平台   int   open   body   获取   border   style   

原生态的JavaScript对DOM的操作 比jquery更方便,特别是当没有id  或class 可以获取的时候,只有用tag名获取

HTML DOM Element 对象操作  http://www.w3school.com.cn/jsref/dom_obj_all.asp

百度开放平台 :http://lbsyun.baidu.com/index.php?title=open/library&qq-pf-to=pcqq.group

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
    #container{
        font-size:12px;
        margin:5px 0;
    }
</style>
<title>
城市列表显示示例</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>


</head>
<body>
<div id="container"></div>
<div style="width:520px;height:340px;border:1px solid gray" id="map_container"></div>

<button type="button" onclick="displayDate()">show</button>

<div id="demo"></div>
</body>
</html>
<script type="text/javascript">
// 新创建地图
var map = new BMap.Map("map_container");
map.centerAndZoom(new BMap.Point(121.478125,31.229649), 12);

var cityList = new BMapLib.CityList({
    container: ‘container‘,
    map: map
});

cityList.getBusiness(‘中关村‘, function(json){
    console.log(‘商圈‘);
    console.log(json);
});

cityList.getSubAreaList(131, function(json){
    console.log(‘城市列表‘);
    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].text+‘\‘‘+‘,‘+‘\‘‘+b.value+‘\‘‘+‘),‘+‘<br>‘;
        }else{

            txt +=‘(\‘‘+c[i].value +‘\‘‘+ ‘,‘ +‘\‘‘+c[i].text+‘\‘‘+‘,‘+‘\‘‘+b.value+‘\‘‘+‘)‘+‘<br>‘;
        }
    };
        var x=document.getElementById("demo");  
        x.innerHTML=txt;

}



</script>

 


<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">    #container{        font-size:12px;        margin:5px 0;    }</style><title>城市列表显示示例</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>

</head><body><div id="container"></div><div style="width:520px;height:340px;border:1px solid gray" id="map_container"></div>
<button type="button" onclick="displayDate()">show</button>
<div id="demo"></div></body></html><script type="text/javascript">// 新创建地图var map = new BMap.Map("map_container");map.centerAndZoom(new BMap.Point(121.478125,31.229649), 12);
var cityList = new BMapLib.CityList({    container: ‘container‘,    map: map});
cityList.getBusiness(‘中关村‘, function(json){    console.log(‘商圈‘);    console.log(json);});
cityList.getSubAreaList(131, function(json){    console.log(‘城市列表‘);    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].text+‘\‘‘+‘,‘+‘\‘‘+b.value+‘\‘‘+‘),‘+‘<br>‘;        }else{
            txt +=‘(\‘‘+c[i].value +‘\‘‘+ ‘,‘ +‘\‘‘+c[i].text+‘\‘‘+‘,‘+‘\‘‘+b.value+‘\‘‘+‘)‘+‘<br>‘;        }    };        var x=document.getElementById("demo");          x.innerHTML=txt;
}


</script>

javascript 之获取 百度地址参数方法

标签:lib   title   开放平台   int   open   body   获取   border   style   

原文地址:http://www.cnblogs.com/jerrypro/p/6565797.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!