js呼叫百度地圖api實現定位
阿新 • • 發佈:2018-12-27
<?php /** * Created by PhpStorm. * User: onlythen * Date: 5/26/15 * Time: 3:23 PM */ session_start(); require_once("config.php"); $link_id=mysql_connect($DBHOST,$DBUSER,$DBPWD); mysql_select_db($DBNAME); $str="select total from number WHERE id=1"; $result=mysql_query($str); $temp=mysql_fetch_array($result); $number=$temp["total"]; //echo $number; $str2="update number set total=total+1 where id=1"; mysql_query($str2); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <!--不可省略--> <script src="http://api.map.baidu.com/api?v=1.5&ak=CqSmd95LZGbKrsshOnjTNUB3" type="text/javascript"></script> </head> <body> <!--不可省略--> <div id="bdMapBox" style="display:none;"></div> <script type="text/javascript"> // 百度地圖API功能 var map = new BMap.Map("bdMapBox"); var nowCity = new BMap.LocalCity(); // var total= document.getElementById("atCity2").innerHTML(); nowCity.get(bdGetPosition); function bdGetPosition(result){ var cityName = result.name; //當前的城市名 /*自定義程式碼*/ atCity.innerHTML = cityName; /*自定義程式碼*/ window.document.title+="我是在"+cityName+<?php echo $number; ?>+"個"+"祝福高考的"; } </script> <!--不可省略--> <p>您當前所在的城市為:<span id="atCity"></span></p> <p>您是第多少個訪問的呢?:<span id="atCity2"><?php echo $number; ?></span></p> </body> </html>