map.html
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{template 'header'}
{template 'member'}
<div class="business">
<div class="tabbable">
<ul class="nav nav-tabs">
<li><a href="{php echo $this->createMobileUrl('detail', array('id' => $item['id']))}">商家信息</a></li>
<li class="active"><a href="{php echo $this->createMobileUrl('map', array('id' => $item['id']))}">地图导航</a></li>
</ul>
</div>
<div id="baidumap" style="height:500px;"></div>
</div>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<script type="text/javascript">
<!--
var bmap = {
'option' : {
'lock' : false,
'container' : 'baidumap',
'infoWindow' : {'width' : 250, 'height' : 100, 'title' : ''},
'point' : {'lng' : 116.403851, 'lat' : 39.915177}
},
'init' : function(option) {
var $this = this;
$this.option = $.extend({},$this.option,option);
$this.option.defaultPoint = new BMap.Point($this.option.point.lng, $this.option.point.lat);
$this.bgeo = new BMap.Geocoder();
$this.bmap = new BMap.Map($this.option.container);
$this.bmap.centerAndZoom($this.option.defaultPoint, 15);
$this.bmap.enableScrollWheelZoom();
$this.bmap.enableDragging();
$this.bmap.enableContinuousZoom();
$this.bmap.addControl(new BMap.NavigationControl());
$this.bmap.addControl(new BMap.OverviewMapControl());
//添加标注
$this.marker = new BMap.Marker($this.option.defaultPoint);
$this.marker.enableDragging();
$this.bmap.addOverlay($this.marker);
}
};
$(function(){
var option = {};
{if !empty($item['lng']) && !empty($item['lat'])}
option = {'point' : {'lng' : '{$item['lng']}', 'lat' : '{$item['lat']}'}}
{/if}
bmap.init(option);
});
//-->
</script>
{template 'footer'}