码迷,mamicode.com
首页 > 编程语言 > 详细

PHP+百度地图API+JAVASCRIPT实现GPS坐标与百度坐标转换的实例

时间:2015-01-08 14:45:07      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:

原文: PHP+百度地图API+JAVASCRIPT实现GPS坐标与百度坐标转换的实例

<!--小幅的坐标转换点位程序-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<?php
	
	$jingwei="new BMap.Point($longitude,$latitude);";
	//$jingwei="new BMap.Point(116.12511,39.72228);";// 测试用的
	
?>
<title>环评项目定位</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
<script type="text/javascript" src="http://dev.baidu.com/wiki/static/map/API/examples/script/convertor.js"></script>  <!--引用用坐标转换脚本-->
</head>
<body>	
	<div style="width:700px;height:250px;margin-left: auto;margin-right: auto;border:1px solid gray"id="container"></div>
</body>
</html>
<script type="text/javascript">
translateCallback = function (point){ //转换坐标
    map.clearOverlays();
	
    var marker = new BMap.Marker(point); //创立坐标点	   
	map.addOverlay(marker); //加入标注
	
    map.setCenter(point);//将传来的点值设为中心点	
    marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
	
	
	map.centerAndZoom(point,15); //设置中心点
	map.addControl(new BMap.NavigationControl());               // 添加平移缩放控件
	map.addControl(new BMap.ScaleControl());                    // 添加比例尺控件
	map.addControl(new BMap.MapTypeControl());          //添加地图类型控件
	map.setCurrentCity("房山");          // 设置地图显示的城市 此项是必须设置的
	map.enableScrollWheelZoom(true);//鼠标缩放
}


var map = new BMap.Map("container",{mapType: BMAP_NORMAL_MAP});      //设置普通地图为底图
var gpsPoint = <?php echo $jingwei?>//将PHP的经纬度值传给JS
    BMap.Convertor.translate(gpsPoint,0,translateCallback);//调用坐标转换函数

</script>


PHP+百度地图API+JAVASCRIPT实现GPS坐标与百度坐标转换的实例

标签:

原文地址:http://www.cnblogs.com/lonelyxmas/p/4210697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!