日期:2014-05-17 浏览次数:20610 次
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2" charset="gb2312"></script> <script type="text/javascript" charset="gb2132"> var map = new BMap.Map("container"); map.centerAndZoom(new BMap.Point('<%=map_x %>', '<%=map_y %>'), 15); var marker = new BMap.Marker(new BMap.Point('<%=map_x %>', '<%=map_y %>'));// create map map.addOverlay(marker); // add mark in the map var opts = {width : 250,height: 100,title : "我的位置"} var infoWindow = new BMap.InfoWindow("<%=comadd%>", opts); // create information Window marker.addEventListener("click", function(){ this.openInfoWindow(infoWindow); }); map.addControl(new BMap.NavigationControl());//NavigationControl map.addControl(new BMap.ScaleControl()); map.addControl(new BMap.OverviewMapControl()); map.addControl(new BMap.MapTypeControl()); map.setCurrentCity("<%=map_city %>"); // 仅当设置城市信息时,MapTypeControl的切换功能才能可用 window.setTimeout(function(){ map.panTo(new BMap.Point('<%=map_x %>', '<%=map_y %>')); }, 2000);//set the Point in the center after 2 minutes //add right-hand button menu in the map var menu = new BMap.ContextMenu(); var txtMenuItem = [{text:'放大',callback:function(){map.zoomIn()}},{text:'缩小',callback:function(){map.zoomOut()}}]; for(var i=0; i < txtMenuItem.length; i++){menu.addItem(new BMap.MenuItem(txtMenuItem[i].text,txtMenuItem[i].callback,100));} map.addContextMenu(menu); </script>
------解决方案--------------------
我还遇到过 要把一些js 写在页面的下面 不可以写在head中
------解决方案--------------------
看看你的版本问题
------解决方案--------------------
贴代码出来