欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

js调用百度地图api实现定位

程序员文章站 2022-06-10 10:42:16
...
<?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>