Created
March 18, 2014 15:27
-
-
Save JingwenTian/9622320 to your computer and use it in GitHub Desktop.
JavaScript API 极速版示例DEMO: http://developer.baidu.com/map/jsmobile.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<script type="text/javascript" src="http://api.map.baidu.com/api?type=quick&ak=22RNa2l6NSorv9rDTbtfp80P&v=1.0"></script> | |
<title>百度地图的Hello, World</title> | |
<style type="text/css"> | |
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;} @media (max-device-width: 780px){#golist{display: block!important;}}#golist {display: none;} | |
</style> | |
</head> | |
<body> | |
<a id="golist" href="../demolist.htm">返回demo列表页</a> | |
<div id="allmap"></div> | |
</body> | |
</html> | |
<script type="text/javascript"> | |
// 百度地图API功能 | |
var map = new BMap.Map("allmap"); // 创建Map实例 | |
var point = new BMap.Point(116.45471,39.913404); // 创建点坐标 | |
map.centerAndZoom(point,15); // 初始化地图,设置中心点坐标和地图级别。 | |
map.addControl(new BMap.ZoomControl()); //添加地图缩放控件 | |
function addMarker(point, index){ // 创建图标对象 | |
var myIcon = new BMap.Icon("http://api.map.baidu.com/mapCard/img/location.gif", | |
new BMap.Size(14, 23), { | |
// 指定定位位置。 | |
// 当标注显示在地图上时,其所指向的地理位置距离图标左上 | |
// 角各偏移7像素和25像素。您可以看到在本例中该位置即是 | |
// 图标中央下端的尖角位置。 | |
anchor: new BMap.Size(7, 25), | |
}); | |
// 创建标注对象并添加到地图 | |
var marker = new BMap.Marker(point, { | |
icon: myIcon | |
}); | |
map.addOverlay(marker); | |
} | |
var point = new BMap.Point(116.45471,39.913404); | |
addMarker(point); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment