57 lines
2.1 KiB
PHP
57 lines
2.1 KiB
PHP
<?php
|
||
include_once("../common/init.php");
|
||
check_login();
|
||
$tb_name = "cars";
|
||
$page = $_REQUEST["page"]?$_REQUEST["page"]:1;
|
||
$list = db_get_all("select * from $tb_name order by id desc");
|
||
|
||
?>
|
||
<?php include_once("base.php");?>
|
||
<style>
|
||
.map_box{height: 600px;}
|
||
</style>
|
||
<body>
|
||
<div id="mapBox" class="map_box"></div>
|
||
<script type="text/javascript">
|
||
window._AMapSecurityConfig = {
|
||
securityJsCode: "0e26a7c047029d1c7144703f185cd763",
|
||
};
|
||
</script>
|
||
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.6&key=1a5277a809d36113ea8c87315b751d75"></script>
|
||
<script>
|
||
var list = <?php echo json_encode($list)?>;
|
||
console.log(list)
|
||
var map = new AMap.Map('mapBox', {
|
||
resizeEnable: true,
|
||
mapStyle: 'amap://styles/c94e78bbbdccdee5a21c45f18da575b1'//样式URL
|
||
});
|
||
map.plugin('AMap.Geolocation', function() {
|
||
geolocation = new AMap.Geolocation({
|
||
enableHighAccuracy: true,//是否使用高精度定位,默认:true
|
||
timeout: 10000, //超过10秒后停止定位,默认:无穷大
|
||
buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
|
||
zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
||
buttonPosition:'RB'
|
||
});
|
||
map.addControl(geolocation);
|
||
geolocation.getCurrentPosition();
|
||
});
|
||
for (var i=0;i<list.length;i++){
|
||
if(list[i].lat > 0 && list[i].lng >0){
|
||
var marker = new AMap.Marker({
|
||
icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_r.png",
|
||
position: [list[i].lat,list[i].lng], //基点位置
|
||
draggable: true, //是否可拖动
|
||
});
|
||
marker.setMap(map);
|
||
marker.setLabel({//label默认蓝框白底左上角显示,样式className为:amap-marker-label
|
||
offset: new AMap.Pixel(-40, -25),//修改label相对于maker的位置
|
||
content: "车牌号:"+list[i].title
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
</script>
|
||
</body>
|
||
</html>
|