百度API接口:http://developer.baidu.com/map/jsdemo.htm#a1_1
百度地图API具体解释之地图标注:http://www.cnblogs.com/jz1108/archive/2011/09/15/2152122.html
【百度地图API】自行获取区域经纬度的工具:http://www.cnblogs.com/milkmap/archive/2012/02/23/2365064.html
酸奶小妹地图系统博客:http://www.cnblogs.com/milkmap/archive/2012/04/11/2442430.html
<?php header("Content-Type:text/html;charset=utf-8"); require_once("../db_config.php"); ?> <?php $sql = "SELECT * FROM `RetailersInfoTable` "; $query = mysql_query($sql); $location=NULL; $clat=0; $clng=0; $i = 0; if(mysql_num_rows($query)) { while($row=mysql_fetch_array($query)) { $i++; $location[]=array( "Longitude"=>$row["Longitude"], "Latitude"=>$row["Latitude"], "name"=>$row["RetailersName"], "kpname"=>$row["RetailersKP"], "kpphone"=>$row["RetailersLeaderPhone"], "rid"=>$row["RID"], "retailersid"=>$row["RetailersID"], ); $clat+=$row["Latitude"]; $clng+=$row["Longitude"]; } $clat = $clat/$i; //平均全部点,以得出初始化定位点 $clng = $clng/$i; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <title>画弧线</title> <link href="../images/css.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=*****************"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/CurveLine/1.5/src/CurveLine.min.js"></script> <style type="text/css"> html,body{ 100%; height:100%; margin:0; overflow:hidden; } </style> </head> <body> <div style="100%;height:100%;border:1px solid gray" id="container"> </div> </body> </html> <script type="text/javascript"> // 百度地图API功能 var map = new BMap.Map("container"); map.centerAndZoom(new BMap.Point(<?php echo $clng?>,<?php echo $clat?>), 13); map.addControl(new BMap.NavigationControl()); //加入默认缩放平移控件 map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL})); //右上角,仅包括平移和缩放button map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT, type: BMAP_NAVIGATION_CONTROL_PAN})); //左下角,仅包括平移button map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM})); //右下角,仅包括缩放button map.enableScrollWheelZoom(); //启用滚轮放大缩小,默认禁用 map.enableContinuousZoom(); //启用地图惯性拖拽,默认禁用 //var points = [p1,p3, p2,p4]; <?php //标注的定位点(anchor),infoWindowAnchor属性,它是用来控制信息窗体开启的位置 foreach($location as $k => $value) { ?> var mPoint = new BMap.Point(<?php echo $value["Longitude"]; ?>, <?php echo $value["Latitude"]; ?>); var myIcon = new BMap.Icon("1.png", new BMap.Size(39,39), { anchor: new BMap.Size(20, 30), infoWindowAnchor: new BMap.Size(20, 0) }); var marker = new BMap.Marker(mPoint,{icon:myIcon}); // 创建标注 map.addOverlay(marker); // 将标注加入到地图中 var infoWindow<?php echo $k;?> = new BMap.InfoWindow("<?php echo '网点名称:'.$value["name"]; echo '</br>'; echo '联系人:'.$value["kpname"]; echo '</br>'; echo '联系电话:'.$value["kpphone"]; echo '</br>'; echo '<a href=../partner/RetailersVisitRecord.php?id='.$value['rid'].'>拜訪记录 </a>'; echo ''; echo '<a href=../retailer/showsalesorder.php?id='.$value['retailersid'].'> 历史销售订单</a>'; ;?>"); marker.addEventListener("mouseover", function(){this.openInfoWindow(infoWindow<?php echo $k;?>);}); <?php } ?> </script>