html5 v2.0百度地图手机触屏缩放地图
<scriptsrc="http://code.jquery.com/jquery-1.11.0.min.js"></script><scripttype="text/j...
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=A607d61b18d43a1ff27abf4ac67da83c"></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
<script>
$(document).ready(function () {
navigator.geolocation.getCurrentPosition(translatePoint); //定位
});
function translatePoint(position){
var currentLat = position.coords.latitude;
var currentLon = position.coords.longitude;
var gpsPoint = new BMap.Point(currentLon, currentLat);
BMap.Convertor.translate(gpsPoint, 0, initMap); //转换坐标
}
function initMap(point){
var map = new BMap.Map("map");
map.centerAndZoom(point, 15);
var myIcon = new BMap.Icon("images/zuobiad.png", new BMap.Size(25,36));
var marker = new BMap.Marker(point, { icon: myIcon });
map.addOverlay(marker);
}
</script>
代码是这样的,但是加了map.addControl(new BMap.ZoomControl());这个之后就出错了,显示不了地图了,我是想触屏地图能够缩放,不知道要加什么代码上去 展开
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=A607d61b18d43a1ff27abf4ac67da83c"></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
<script>
$(document).ready(function () {
navigator.geolocation.getCurrentPosition(translatePoint); //定位
});
function translatePoint(position){
var currentLat = position.coords.latitude;
var currentLon = position.coords.longitude;
var gpsPoint = new BMap.Point(currentLon, currentLat);
BMap.Convertor.translate(gpsPoint, 0, initMap); //转换坐标
}
function initMap(point){
var map = new BMap.Map("map");
map.centerAndZoom(point, 15);
var myIcon = new BMap.Icon("images/zuobiad.png", new BMap.Size(25,36));
var marker = new BMap.Marker(point, { icon: myIcon });
map.addOverlay(marker);
}
</script>
代码是这样的,但是加了map.addControl(new BMap.ZoomControl());这个之后就出错了,显示不了地图了,我是想触屏地图能够缩放,不知道要加什么代码上去 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询