奥罗塞,撒丁岛,意大利 (© EyeEm Mobile GmbH/Getty Images)

Welcom to 评论 - lizhenqiu blog!

    #2053

    作者:广西南宁市
    百度地图PC版代码
    <div class="ditu" id="map" style="width:900px; height:396px; border:1px solid #ccc; margin:15px auto 0 auto;"></div> <script src="http://api.map.baidu.com/api?v=1.3" type="text/javascript"></script> <script type="text/javascript"> //创建和初始化地图函数: function initMap(){ createMap();//创建地图 setMapEvent();//设置地图事件 addMapControl();//向地图添加控件 addMapOverlay();//向地图添加覆盖物 } function createMap(){ map = new BMap.Map("map"); map.centerAndZoom(new BMap.Point(<?php echo $longitude;?>,<?php echo $latitude;?>),19); } function setMapEvent(){ map.enableScrollWheelZoom(); map.enableKeyboard(); map.enableDragging(); map.enableDoubleClickZoom() } function addClickHandler(target,window){ target.addEventListener("click",function(){ target.openInfoWindow(window); }); } function addMapOverlay(){ var markers = [ {content:"<?php echo $address;?>",title:"<?php echo $company;?>",imageOffset: {width:-46,height:-21 },position:{lat:<?php echo $latitude;?>,lng:<?php echo $longitude;?>}} ]; for(var index = 0; index < markers.length; index++ ){ var point = new BMap.Point(markers[index].position.lng,markers[index].position.lat); var marker = new BMap.Marker(point,{icon:new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png",new BMap.Size(20,25),{ imageOffset: new BMap.Size(markers[index].imageOffset.width,markers[index].imageOffset.height) })}); var label = new BMap.Label(markers[index].title,{offset: new BMap.Size(25,5)}); var opts = { width: 200, title: markers[index].title, enableMessage: false }; var infoWindow = new BMap.InfoWindow(markers[index].content,opts); marker.setLabel(label); addClickHandler(marker,infoWindow); map.addOverlay(marker); }; } //向地图添加控件 function addMapControl(){ var scaleControl = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT}); scaleControl.setUnit(BMAP_UNIT_IMPERIAL); map.addControl(scaleControl); var navControl = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE}); map.addControl(navControl); var overviewControl = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:false}); map.addControl(overviewControl); } var map; initMap(); </script>
    Run code
    Cut to clipboard
      文章:百度地图显示多个标注点  发表时间:2016-11-02, 18:01:44  
      展开↯

      #2054

      作者:广西南宁市
      广羽人门店分布地图多点标注2
      添加设置覆盖物标注点文字标签
      <GZ:list sql="select * from gz_mendianbiaozhu where status='1' order by listorder desc" key='i'> <?php $meidanfenbu[]=$r; ?> </GZ:list> <!---------------------------------------- 栏目 start ----------------------------------------> <div class="lanmu"> <ul class="xuanxiang xuanxiangnew-lij clearfix"><include file="A:l"/> </ul> </div> <!---------------------------------------- 栏目 end ----------------------------------------> <?php $zms=array( '1'=>'A', '2'=>'B', '3'=>'C', '4'=>'D', '5'=>'E', '6'=>'F', '7'=>'G', '8'=>'H', '9'=>'I', '10'=>'J', '11'=>'K', '12'=>'L', '13'=>'M', '14'=>'N', '15'=>'O', '16'=>'P', '17'=>'Q', '18'=>'R', '19'=>'S', '20'=>'T', '21'=>'U', '22'=>'V', '23'=>'W', '24'=>'X', '25'=>'Y', '26'=>'Z' ); ?> <!---------------------------------------- 门店分布内容 start ----------------------------------------> <div class="mdfbbox"> <div class="fbbt">广西南宁市范围广羽人门店分布地图:</div> <div class="gxditu" id="map" style="width:900px; height:365px; border:1px solid #ccc;"></div> <div class="fbbt" style="margin-top:30px;">广西南宁市广羽人所有店铺地址:</div> <div class="fbdzlf" style="width:900px; border-right: none;"><?php foreach($meidanfenbu as $i=>$r){ $ik++; if($nnssvs) $nnssvs.= ',{ title: "'.$r['mingc'].'", point: "'.$r['zuobo'].'", address: "'.$r['dizhi'].'",tel:"'.$r['tel'].'"}'; else $nnssvs= '{ title: "名称:'.$r['mingc'].'", point: "'.$r['zuobo'].'", address: "'.$r['dizhi'].'",tel:"'.$r['tel'].'"}'; $lns=explode(',',$r['zuobo']); $ln=$lns['0']; $la=$lns['1']; ?> <div onclick="getdddsnew('{$ln}','{$la}','{$r.mingc}','{$r.dizhi}','{$r.tel}');" style="cursor: pointer;float:left;<?php if(($i%2)) echo 'width:425px;margin-left: 25px;'; else echo 'width:448px; border-right: 1px dashed #ccc;'; //if($i>2) echo 'margin-top: 15px;'; ?>padding-bottom:15px;"> <div style="width:100%;" class="dianming"><span style="color:red;"><?php echo $zms[$ik];?></span> {$r.mingc}</div> <P style="width:100%;" class="diandizhi" style="margin-bottom:15px;">{$r.dizhi}</P></div> <?php } ?> </div> </div> <!---------------------------------------- 门店分布内容 end ----------------------------------------> <script> var load = document.createElement("script"); load.src = "http://api.map.baidu.com/api?v=1.4&callback=map_init"; document.body.appendChild(load); var markerArr = [ <?php echo $nnssvs;?> //{ title: "名称:金外滩商务大厦", point: "108.33058,22.815521", address: "金外滩商务大厦1301"}, //{ title: "名称:人民公园", point: "108.336858,22.83404", address: "人民公园地址<br>电话13607875450 "} ]; //var map; //Map实例 //map = new BMap.Map("map"); function map_init() { map = new BMap.Map("map"); //第1步:设置地图中心点,南宁市政府 var point = new BMap.Point(108.33058,22.815521); //第2步:初始化地图,设置中心点坐标和地图级别。 map.centerAndZoom(point, 13); //第3步:启用滚轮放大缩小 map.enableScrollWheelZoom(true); //第4步:向地图中添加缩放控件 var ctrlNav = new window.BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE }); map.addControl(ctrlNav); //第5步:向地图中添加缩略图控件 var ctrlOve = new window.BMap.OverviewMapControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 1 }); map.addControl(ctrlOve); //第6步:向地图中添加比例尺控件 var ctrlSca = new window.BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT }); map.addControl(ctrlSca); //第7步:绘制点 for (var i = 0; i < markerArr.length; i++) { var p0 = markerArr[i].point.split(",")[0]; var p1 = markerArr[i].point.split(",")[1]; var maker = addMarker(new window.BMap.Point(p0, p1), i); // i 标注字母顺序 addInfoWindow(maker, markerArr[i], i); } } // 添加标注 function addMarker(point, index) { var myIcon = new BMap.Icon("http://api.map.baidu.com/img/markers.png", new BMap.Size(23, 25), { offset: new BMap.Size(10, 25), imageOffset: new BMap.Size(0, 0 - index * 25) }); var marker = new BMap.Marker(point, { icon: myIcon }); map.addOverlay(marker); //设置覆盖物的文字标签 var label = new BMap.Label(markerArr[index].title,{offset:new BMap.Size(20,-10)}); marker.setLabel(label); //end return marker; } // 添加信息窗口 function addInfoWindow(marker, poi) { //pop弹窗标题 var title = '<div style="font-weight:bold;color:#CE5521;font-size:14px">' + poi.title + '</div>'; //pop弹窗信息 var html = []; html.push('<p style="vertical-align:top;line-height:16px">地址:'+poi.address+'</p><p style="vertical-align:top;line-height:16px">电话:'+poi.tel+'</p>'); /*html.push('<table cellspacing="0" style="table-layout:fixed;width:100%;font:12px arial,simsun,sans-serif"><tbody>'); html.push('<tr>'); html.push('<td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">地址:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + poi.address + ' </td>'); html.push('</tr><tr><td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">电话:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + poi.tel + ' </td>'); html.push('</tr>'); html.push('</tbody></table>'); */ var infoWindow = new BMap.InfoWindow(html.join(""), { title: title/*, width: 200*/ }); var openInfoWinFun = function () { marker.openInfoWindow(infoWindow); }; marker.addEventListener("click", openInfoWinFun); return openInfoWinFun; } //异步调用百度js /*function map_load() { var load = document.createElement("script"); load.src = "http://api.map.baidu.com/api?v=1.4&callback=map_init"; document.body.appendChild(load); } window.onload = map_load; */ //点击打开标注点移动到标注点地图中心 function getdddsnew(ln,la,title,address,tel){ //pop弹窗标题 var title = '<div style="font-weight:bold;color:#CE5521;font-size:14px">' + title + '</div>'; //pop弹窗信息 /*var html = []; html.push('<table cellspacing="0" style="table-layout:fixed;width:100%;font:12px arial,simsun,sans-serif"><tbody>'); html.push('<tr>'); html.push('<td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">地址:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + address + ' </td>'); html.push('</tr><tr><td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">电话:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + tel + ' </td>'); html.push('</tr>'); html.push('</tbody></table>');*/ html='<p style="vertical-align:top;line-height:16px">地址:'+address+'</p><p style="vertical-align:top;line-height:16px">电话:'+tel+'</p>'; //alert(lnat); //map.panTo(new BMap.Point(116.409, 39.918));平滑移动至新中心点 如果移动距离超过了当前地图区域大小,则地图会直跳到该点。 var Point=new BMap.Point(ln,la); var opts = { //width : 250, // 信息窗口宽度 //height: 100, // 信息窗口高度 title : title // 信息窗口标题 } var infoWindow = new BMap.InfoWindow(html, opts); // 创建信息窗口对象 //map.openInfoWindow(infoWindow, map.getCenter()); // 打开信息窗口 map.openInfoWindow(infoWindow, Point); } //map.panTo(new BMap.Point(116.409, 39.918)); </script>
      Run code
      Cut to clipboard

        百度地图API示例 百度地图API JavaScript API > 开发指南
        文章:百度地图显示多个标注点  发表时间:2016-11-02, 18:00:29  
        展开↯

        #2055

        作者:广西南宁市
        广羽人优化后版本1
        新增点击移动到标注点打开标注点信息窗口
        <GZ:list sql="select * from gz_mendianbiaozhu where status='1' order by listorder desc" key='i'> <?php $meidanfenbu[]=$r; ?> </GZ:list> <!---------------------------------------- 栏目 start ----------------------------------------> <div class="lanmu"> <ul class="xuanxiang xuanxiangnew-lij clearfix"><include file="A:l"/> </ul> </div> <!---------------------------------------- 栏目 end ----------------------------------------> <?php $zms=array( '1'=>'A', '2'=>'B', '3'=>'C', '4'=>'D', '5'=>'E', '6'=>'F', '7'=>'G', '8'=>'H', '9'=>'I', '10'=>'J', '11'=>'K', '12'=>'L', '13'=>'M', '14'=>'N', '15'=>'O', '16'=>'P', '17'=>'Q', '18'=>'R', '19'=>'S', '20'=>'T', '21'=>'U', '22'=>'V', '23'=>'W', '24'=>'X', '25'=>'Y', '26'=>'Z' ); ?> <!---------------------------------------- 门店分布内容 start ----------------------------------------> <div class="mdfbbox"> <div class="fbbt">广西南宁市范围广羽人门店分布地图:</div> <div class="gxditu" id="map" style="width:900px; height:365px; border:1px solid #ccc;"></div> <div class="fbbt" style="margin-top:30px;">广西南宁市广羽人所有店铺地址:</div> <div class="fbdzlf" style="width:900px; border-right: none;"><?php foreach($meidanfenbu as $i=>$r){ $ik++; if($nnssvs) $nnssvs.= ',{ title: "'.$r['mingc'].'", point: "'.$r['zuobo'].'", address: "'.$r['dizhi'].'",tel:"'.$r['tel'].'"}'; else $nnssvs= '{ title: "名称:'.$r['mingc'].'", point: "'.$r['zuobo'].'", address: "'.$r['dizhi'].'",tel:"'.$r['tel'].'"}'; $lns=explode(',',$r['zuobo']); $ln=$lns['0']; $la=$lns['1']; ?> <div onclick="getdddsnew('{$ln}','{$la}','{$r.mingc}','{$r.dizhi}','{$r.tel}');" style="cursor: pointer;float:left;<?php if(($i%2)) echo 'width:425px;margin-left: 25px;'; else echo 'width:448px; border-right: 1px dashed #ccc;'; //if($i>2) echo 'margin-top: 15px;'; ?>padding-bottom:15px;"> <div style="width:100%;" class="dianming"><span style="color:red;"><?php echo $zms[$ik];?></span> {$r.mingc}</div> <P style="width:100%;" class="diandizhi" style="margin-bottom:15px;">{$r.dizhi}</P></div> <?php } ?> </div> </div> <!---------------------------------------- 门店分布内容 end ----------------------------------------> <script> var load = document.createElement("script"); load.src = "http://api.map.baidu.com/api?v=1.4&callback=map_init"; document.body.appendChild(load); var markerArr = [ <?php echo $nnssvs;?> //{ title: "名称:金外滩商务大厦", point: "108.33058,22.815521", address: "金外滩商务大厦1301"}, //{ title: "名称:人民公园", point: "108.336858,22.83404", address: "人民公园地址<br>电话13607875450 "} ]; //var map; //Map实例 //map = new BMap.Map("map"); function map_init() { map = new BMap.Map("map"); //第1步:设置地图中心点,南宁市政府 var point = new BMap.Point(108.33058,22.815521); //第2步:初始化地图,设置中心点坐标和地图级别。 map.centerAndZoom(point, 13); //第3步:启用滚轮放大缩小 map.enableScrollWheelZoom(true); //第4步:向地图中添加缩放控件 var ctrlNav = new window.BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE }); map.addControl(ctrlNav); //第5步:向地图中添加缩略图控件 var ctrlOve = new window.BMap.OverviewMapControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 1 }); map.addControl(ctrlOve); //第6步:向地图中添加比例尺控件 var ctrlSca = new window.BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT }); map.addControl(ctrlSca); //第7步:绘制点 for (var i = 0; i < markerArr.length; i++) { var p0 = markerArr[i].point.split(",")[0]; var p1 = markerArr[i].point.split(",")[1]; var maker = addMarker(new window.BMap.Point(p0, p1), i); // i 标注字母顺序 addInfoWindow(maker, markerArr[i], i); } } // 添加标注 function addMarker(point, index) { var myIcon = new BMap.Icon("http://api.map.baidu.com/img/markers.png", new BMap.Size(23, 25), { offset: new BMap.Size(10, 25), imageOffset: new BMap.Size(0, 0 - index * 25) }); var marker = new BMap.Marker(point, { icon: myIcon }); map.addOverlay(marker); return marker; } // 添加信息窗口 function addInfoWindow(marker, poi) { //pop弹窗标题 var title = '<div style="font-weight:bold;color:#CE5521;font-size:14px">' + poi.title + '</div>'; //pop弹窗信息 var html = []; html.push('<p style="vertical-align:top;line-height:16px">地址:'+poi.address+'</p><p style="vertical-align:top;line-height:16px">电话:'+poi.tel+'</p>'); /*html.push('<table cellspacing="0" style="table-layout:fixed;width:100%;font:12px arial,simsun,sans-serif"><tbody>'); html.push('<tr>'); html.push('<td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">地址:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + poi.address + ' </td>'); html.push('</tr><tr><td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">电话:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + poi.tel + ' </td>'); html.push('</tr>'); html.push('</tbody></table>'); */ var infoWindow = new BMap.InfoWindow(html.join(""), { title: title/*, width: 200*/ }); var openInfoWinFun = function () { marker.openInfoWindow(infoWindow); }; marker.addEventListener("click", openInfoWinFun); return openInfoWinFun; } //异步调用百度js /*function map_load() { var load = document.createElement("script"); load.src = "http://api.map.baidu.com/api?v=1.4&callback=map_init"; document.body.appendChild(load); } window.onload = map_load; */ //点击打开标注点移动到标注点地图中心 function getdddsnew(ln,la,title,address,tel){ //pop弹窗标题 var title = '<div style="font-weight:bold;color:#CE5521;font-size:14px">' + title + '</div>'; //pop弹窗信息 /*var html = []; html.push('<table cellspacing="0" style="table-layout:fixed;width:100%;font:12px arial,simsun,sans-serif"><tbody>'); html.push('<tr>'); html.push('<td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">地址:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + address + ' </td>'); html.push('</tr><tr><td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">电话:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + tel + ' </td>'); html.push('</tr>'); html.push('</tbody></table>');*/ html='<p style="vertical-align:top;line-height:16px">地址:'+address+'</p><p style="vertical-align:top;line-height:16px">电话:'+tel+'</p>'; //alert(lnat); //map.panTo(new BMap.Point(116.409, 39.918));平滑移动至新中心点 如果移动距离超过了当前地图区域大小,则地图会直跳到该点。 var Point=new BMap.Point(ln,la); var opts = { //width : 250, // 信息窗口宽度 //height: 100, // 信息窗口高度 title : title // 信息窗口标题 } var infoWindow = new BMap.InfoWindow(html, opts); // 创建信息窗口对象 //map.openInfoWindow(infoWindow, map.getCenter()); // 打开信息窗口 map.openInfoWindow(infoWindow, Point); } //map.panTo(new BMap.Point(116.409, 39.918)); </script>
        Run code
        Cut to clipboard
          文章:百度地图显示多个标注点  发表时间:2016-11-02, 17:49:12  
          展开↯

          #2056

          作者:广西南宁市
          关于百度地图api标注点marker的click事件问题
          百度地图在地图中给标注点marker添加后click事件后 marker.addEventListener("click", function(){}) 如何在其他地方自动触发这个marker点击事件? 因为输出marker是一个对象,所以并不能marker.click() 想做的就是如百度地图那样点击左边搜索结果栏右边标注点自动点击一次
          Run code
          Cut to clipboard

            感觉api确实不太好用,想出来俩解决方案。

            1.可以定义好事件处理函数,想要触发时执行一遍:
            marker.addEventListener('click',func); function func(){ alert(); } // 想要触发时,直接调用func func();
            Run code
            Cut to clipboard

              2.发现marker有一个属性B指向标记DOM,但B只在地图加载完成后才有值,否则为null,所以可以在地图加载完成后给给B绑定事件.
              map.addEventListener("tilesloaded",function(){ marker.B.addEventListener('click',function(){ alert(); }); /* 使用zepto或jQuery $(marker.B).on('click',function(){ alert(); }); */ }); // 注意触发时要保证地图加载完成 marker.B.click(); /* 或 $(marker.B).trigger('click'); */
              Run code
              Cut to clipboard


                也可以不等地图加载完,定义marker后就直接绑定,但触发时还是触发marker.B也是可以的。
                marker.addEventListener('click',function(){ alert(); }); // 注意触发时要保证地图加载完成 marker.B.click();
                Run code
                Cut to clipboard
                  文章:百度地图显示多个标注点  发表时间:2016-11-02, 15:44:49  
                  展开↯

                  #2057

                  作者:广西南宁市
                  <GZ:list sql="select * from gz_mendianbiaozhu where status='1' order by listorder desc" key='i'> <?php $meidanfenbu[]=$r; ?> </GZ:list> <!---------------------------------------- 栏目 start ----------------------------------------> <div class="lanmu"> <ul class="xuanxiang xuanxiangnew-lij clearfix"><include file="A:l"/> </ul> </div> <!---------------------------------------- 栏目 end ----------------------------------------> <?php $zms=array( '1'=>'A', '2'=>'B', '3'=>'C', '4'=>'D', '5'=>'E', '6'=>'F', '7'=>'G', '8'=>'H', '9'=>'I', '10'=>'J', '11'=>'K', '12'=>'L', '13'=>'M', '14'=>'N', '15'=>'O', '16'=>'P', '17'=>'Q', '18'=>'R', '19'=>'S', '20'=>'T', '21'=>'U', '22'=>'V', '23'=>'W', '24'=>'X', '25'=>'Y', '26'=>'Z' ); ?> <!---------------------------------------- 门店分布内容 start ----------------------------------------> <div class="mdfbbox"> <div class="fbbt">广西南宁市范围广羽人门店分布地图:</div> <div class="gxditu" id="map" style="width:900px; height:365px; border:1px solid #ccc;"></div> <div class="fbbt" style="margin-top:30px;">广西南宁市广羽人所有店铺地址:</div> <div class="fbdzlf" style="width:900px; border-right: none;"><?php foreach($meidanfenbu as $i=>$r){ $ik++; if($nnssvs) $nnssvs.= ',{ title: "'.$r['mingc'].'", point: "'.$r['zuobo'].'", address: "'.$r['dizhi'].'",tel:"'.$r['tel'].'"}'; else $nnssvs= '{ title: "名称:'.$r['mingc'].'", point: "'.$r['zuobo'].'", address: "'.$r['dizhi'].'",tel:"'.$r['tel'].'"}'; ?> <div style="float:left;<?php if(($i%2)) echo 'width:425px;margin-left: 25px;'; else echo 'width:448px; border-right: 1px dashed #ccc;'; //if($i>2) echo 'margin-top: 15px;'; ?>padding-bottom:15px;"> <div style="width:100%;" class="dianming"><span style="color:red;"><?php echo $zms[$ik];?></span> {$r.mingc}</div> <P style="width:100%;" class="diandizhi" style="margin-bottom:15px;">{$r.dizhi}</P></div> <?php } ?> </div> </div> <!---------------------------------------- 门店分布内容 end ----------------------------------------> <script> var markerArr = [ <?php echo $nnssvs;?> //{ title: "名称:金外滩商务大厦", point: "108.33058,22.815521", address: "金外滩商务大厦1301"}, //{ title: "名称:人民公园", point: "108.336858,22.83404", address: "人民公园地址<br>电话13607875450 "} ]; var map; //Map实例 function map_init() { map = new BMap.Map("map"); //第1步:设置地图中心点,南宁市政府 var point = new BMap.Point(108.33058,22.815521); //第2步:初始化地图,设置中心点坐标和地图级别。 map.centerAndZoom(point, 13); //第3步:启用滚轮放大缩小 map.enableScrollWheelZoom(true); //第4步:向地图中添加缩放控件 var ctrlNav = new window.BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE }); map.addControl(ctrlNav); //第5步:向地图中添加缩略图控件 var ctrlOve = new window.BMap.OverviewMapControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 1 }); map.addControl(ctrlOve); //第6步:向地图中添加比例尺控件 var ctrlSca = new window.BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT }); map.addControl(ctrlSca); //第7步:绘制点 for (var i = 0; i < markerArr.length; i++) { var p0 = markerArr[i].point.split(",")[0]; var p1 = markerArr[i].point.split(",")[1]; var maker = addMarker(new window.BMap.Point(p0, p1), i); addInfoWindow(maker, markerArr[i], i); } } // 添加标注 function addMarker(point, index) { var myIcon = new BMap.Icon("http://api.map.baidu.com/img/markers.png", new BMap.Size(23, 25), { offset: new BMap.Size(10, 25), imageOffset: new BMap.Size(0, 0 - index * 25) }); var marker = new BMap.Marker(point, { icon: myIcon }); map.addOverlay(marker); return marker; } // 添加信息窗口 function addInfoWindow(marker, poi) { //pop弹窗标题 var title = '<div style="font-weight:bold;color:#CE5521;font-size:14px">' + poi.title + '</div>'; //pop弹窗信息 var html = []; html.push('<table cellspacing="0" style="table-layout:fixed;width:100%;font:12px arial,simsun,sans-serif"><tbody>'); html.push('<tr>'); html.push('<td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">地址:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + poi.address + ' </td>'); html.push('</tr><tr><td style="vertical-align:top;line-height:16px;width:38px;white-space:nowrap;word-break:keep-all">电话:</td>'); html.push('<td style="vertical-align:top;line-height:16px">' + poi.tel + ' </td>'); html.push('</tr>'); html.push('</tbody></table>'); var infoWindow = new BMap.InfoWindow(html.join(""), { title: title, width: 200 }); var openInfoWinFun = function () { marker.openInfoWindow(infoWindow); }; marker.addEventListener("click", openInfoWinFun); return openInfoWinFun; } //异步调用百度js function map_load() { var load = document.createElement("script"); load.src = "http://api.map.baidu.com/api?v=1.4&callback=map_init"; document.body.appendChild(load); } window.onload = map_load; //map.panTo(new BMap.Point(116.409, 39.918)); </script>
                  Run code
                  Cut to clipboard
                    文章:百度地图显示多个标注点  发表时间:2016-11-02, 15:43:10  
                    展开↯

                    #2058

                    作者:广西南宁市
                    卧槽,一直没弄成多个自定义覆盖物,原来 精髓在这里
                    var point = new Array(); var marker = new Array(); var info = new Array();
                    Run code
                    Cut to clipboard

                      太感谢楼主了
                      文章:百度地图显示多个标注点  发表时间:2016-11-02, 15:39:39  
                      展开↯

                      #2059

                      作者:广西南宁市
                      老贾吹牛逼世界第一。
                      文章:他不是脾气暴躁,只是不能被打扰  发表时间:2016-11-02, 15:26:26  
                      展开↯

                      #2060

                      作者:广西南宁市
                      用户要什么给什么那是销售,告诉用户应该要什么才是营销。
                      文章:他不是脾气暴躁,只是不能被打扰  发表时间:2016-11-02, 14:58:23  
                      展开↯

                      #2061

                      作者:广西南宁市
                      甲之蜜糖,乙之砒霜。
                      文章:他不是脾气暴躁,只是不能被打扰  发表时间:2016-11-02, 14:55:57  
                      展开↯

                      #2063

                      作者:广西南宁市
                      php中关于长度计算容易混淆的问题分析
                      本文实例讲述了php中关于长度计算容易混淆的问题。
                      经常被php中数组和字符串的字符函数搞晕,下面总结一下:

                      strlen($string)函数:计算字符串的长度;
                      sizeof($string,$mode)函数:它是count()函数的别名,count()函数如下:
                      int count ( mixed var [, int mode] )
                      返回 var 中的单元数目,通常是一个 array,任何其它类型都只有一个单元。

                      对于对象,如果安装了 SPL,可以通过实现 Countable 接口来调用 count()。该接口只有一个方法 count(),此方法返回 count() 函数的返回值。
                      如果 var 不是数组类型或者实现了 Countable 接口的对象,将返回 1,有一个例外,如果 var 是 NULL 则结果是 0。
                      注: 可选的 mode 参数自 PHP 4.2.0 起可用。

                      如果可选的 mode 参数设为 COUNT_RECURSIVE(或 1),count() 将递归地对数组计数。对计算多维数组的所有单元尤其有用。mode 的默认值是 0。count() 识别不了无限递归。

                      总之,字符串用strlen(),数组用sizeof()即可。

                      《php操作office文档技巧总结(包括word,excel,access,ppt)》《PHP数组(Array)操作技巧大全》《php排序算法总结》《PHP常用遍历算法与技巧总结》《PHP数据结构与算法教程》《php程序设计算法总结》《PHP数学运算技巧总结》《php正则表达式用法总结》《PHP运算与运算符用法总结》《php字符串(string)用法总结》《php常见数据库操作技巧汇总》
                      文章:利用PHP函数计算中英文字符串长度的方法  发表时间:2016-11-02, 11:19:47  
                      展开↯

                      #2064

                      作者:广西南宁市
                      PHP 字符串长度判断效率更高的方法

                      在php里当需要判断一个字符串长度时,我们首先想到的是strlen()函数,不错,strlen()返回的就是字符串的长度,这样使用没有任何问题。不过,如果要从php程序优化的角度来看,使用strlen()判断字符串长度未免是最好的写法
                      有经验的程序员发现,php判断字符串长度,使用isset()在速度上比strlen()更快,执行效率更高。
                      即:
                      $str = ‘aaaaaa'; if(strlen($str) > 6) VS if(!isset($str{6})
                      Run code
                      Cut to clipboard


                        用例子简单测试下,情况基本属实,isset()效率几乎是strlen()的3倍。
                        示例:
                        <?php //使用strlen方式 $arr = "123456"; $sTime = microtime(1); if(strlen($arr) > 6){ // echo 1; } echo microtime(1) - $sTime;
                        Run code
                        Cut to clipboard

                          输出:0.00035595893859863
                          <?php //使用isset($arr{})方式 $arr = "123456"; $sTime = microtime(1); if(!isset($arr{6})){ // echo "1\r\n"; } echo microtime(1) - $sTime;
                          Run code
                          Cut to clipboard

                            输出:0.00019097328186035

                            isset()速度为什么比strlen()更快
                            strlen()函数函数执行起来相当快,因为它不做任何计算,只返回在zval 结构(C的内置数据结构,用于存储PHP变量)中存储的已知字符串长度。但是,由于strlen()是函数,多多少少会有些慢,因为函数调用会经过诸多步骤,如字母小写化(译注:指函数名小写化,PHP不区分函数名大小写)、哈希查找,会跟随被调用的函数一起执行。

                            在某些情况下,使用isset() 技巧可以加速执行你的代码。因为与isset()作为一种语言结构,意味着它的执行不需要函数查找和字母小写化。也就是说,实际上在检验字符串长度的顶层代码中你没有花太多开销。

                            因此调用isset()比strlen()快。
                            文章:利用PHP函数计算中英文字符串长度的方法  发表时间:2016-11-02, 11:06:08  
                            展开↯

                            #2065

                            作者:广西南宁市
                            PHP英文字母大小写转换函数小结

                            每个单词的首字母转换为大写:ucwords()
                            <?php $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwords($bar); // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World!
                            Run code
                            Cut to clipboard


                              第一个单词首字母变大写:ucfirst()
                              <?php $foo = 'hello world!'; $foo = ucfirst($foo); // Hello world! $bar = 'HELLO WORLD!'; $bar = ucfirst($bar); // HELLO WORLD! $bar = ucfirst(strtolower($bar)); // Hello world!
                              Run code
                              Cut to clipboard


                                第一个单词首字母变小写:lcfirst()
                                <?php $foo = 'HelloWorld'; $foo = lcfirst($foo); // helloWorld $bar = 'HELLO WORLD!'; $bar = lcfirst($bar); // hELLO WORLD! $bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
                                Run code
                                Cut to clipboard

                                  所有字母变大写:strtoupper() 所有字母变小写:strtolower()
                                  Run code
                                  Cut to clipboard
                                    文章:PHP的大小写敏感问题整理  发表时间:2016-11-02, 11:03:59  
                                    展开↯

                                    #2066

                                    作者:广西南宁市
                                    php中计算未知长度的字符串哪个字符出现的次数最多的代码
                                    第一种方法:
                                    用到的函数:
                                    str_split:把字符串分割到数组中。类似的函数explode() 函数把字符串分割为数组。array_count_values:用于统计数组中所有值出现的次数。
                                    arsort:对数组进行逆向排序并保持索引关系。
                                    主要用于对那些单元顺序很重要的结合数组进行排序。$str="asdfgfdas323344##$\$fdsdfg*$**$*$**$$443563536254fas";//任意长度字符串
                                    代码如下:
                                    $arr=str_split($str); $arr=array_count_values($arr); arsort($arr); print_r($arr);
                                    Run code
                                    Cut to clipboard

                                      输出:
                                      Array( [$] => 7 [3] => 6 [*] => 6 [4] => 5 [f] => 5 [s] => 4 [d] => 4 [5] => 3 [a] => 3 [6] => 2 [2] => 2 [g] => 2 [#] => 2 )
                                      Run code
                                      Cut to clipboard


                                        第二种方法:
                                        用到的函数:
                                        array_unique:删除数组中重复的值。substr_count:计算子串在字符串中出现的次数。
                                        代码如下:
                                        $str="asdfgfdas323344##$\$fdsdfg*$**$*$**$$443563536254fas";//任意长度字符串 $arr=str_split($str); $unique=array_unique($arr); foreach ($unique as $a){ $arr2[$a]=substr_count($str, $a); } arsort($arr2); print_r($arr2);
                                        Run code
                                        Cut to clipboard
                                          文章:利用PHP函数计算中英文字符串长度的方法  发表时间:2016-11-02, 11:01:20  
                                          展开↯

                                          #2067

                                          作者:广西南宁市
                                          文章:PHP的大小写敏感问题整理  发表时间:2016-11-02, 10:52:07  
                                          展开↯

                                          #2068

                                          作者:广西南宁市
                                          php根据操作系统转换文件名大小写的方法
                                          if(is_file($fileName)){ //PHP_OS 当前运行的操作系统 if(strstr(PHP_OS,'WIN')){ //realpath($fileName) 会转换文件名的大小写 /web/A.php 如果A.php不存在而a.php则会返回/web/a.php if(basename(realpath($fileName)) == basename($fileName)) require $fileName; else echo '请检查文件的大小写'; }else require $fileName; }
                                          Run code
                                          Cut to clipboard
                                            文章:PHP的大小写敏感问题整理  发表时间:2016-11-02, 10:51:27  
                                            展开↯

                                            #2069

                                            作者:广西南宁市
                                            Array ( [1] => 1 [2] => 1 [4] => 1 [5] => 2 [6] => 1 [7] => 2 [10] => 1 [11] => 2 [12] => 3 [13] => 4 [14] => 2 [15] => 3 [16] => 2 [17] => 3 [18] => 1 [19] => 2 [20] => 3 [21] => 4 [22] => 1 [23] => 2 [24] => 3 [25] => 4 [26] => 2 [27] => 3 [28] => 4 [29] => 2 [30] => 3 [31] => 4 [32] => 1 [33] => 3 [34] => 4 [35] => 1 [36] => 3 [37] => 4 [38] => 1 [39] => 2 [40] => 3 [41] => 1 [42] => 2 [43] => 3 [44] => 1 [45] => 2 [46] => 3 [47] => 1 [48] => 2 [49] => 3 [50] => 2 [51] => 4 [52] => 1 [53] => 2 [54] => 4 [55] => 1 [56] => 1 [57] => 2 [58] => 3 [59] => 1 [60] => 2 [61] => 3 [62] => 1 [63] => 2 [64] => 3 [65] => 1 [66] => 2 [67] => 3 )
                                            Run code
                                            Cut to clipboard

                                              有个盲点,类似上面这样的结构想统计‘1’有几个,统计不了。
                                              文章:PHP获取数组中重复数据  发表时间:2016-11-02, 10:39:12  
                                              展开↯

                                              #2070

                                              作者:广西南宁市
                                              PHP里判断2个数组值是否相同 不相同的值取出来放进另外一个数组
                                              array_merge搜索(array_diff($arr1, array_intersect($arr1, $arr2)), array_diff($arr2, array_intersect($arr1, $arr2)));
                                              Run code
                                              Cut to clipboard
                                                文章:PHP获取数组中重复数据  发表时间:2016-11-02, 10:26:36  
                                                展开↯

                                                #2071

                                                作者:北京市
                                                一个小女孩到西饼店买早点。她对老板说:老板!买个巧克力娃娃。老板:你要男娃还是女娃?女孩:当然是要男娃娃喽!因为能吃的地方多了一点。
                                                文章:他不是脾气暴躁,只是不能被打扰  发表时间:2016-11-01, 20:30:38  
                                                展开↯
                                                你好,残忍屏蔽广告

                                                确定要清除编辑框内容吗?

                                                该删除操作将不可恢复。

                                                删除 取消

                                                激活Windows

                                                转到"设置"以激活Windows。