云狐网

您现在的位置是:首页 > 网站建设 > cms系统

cms系统

旅游资讯站使用帝国cms添加百度API地图,默认显示提示框

云狐数码 2023-02-21 16:53:37cms系统

百度API地图显示效果如图:tBv电脑_数码_手机应用问题解决的IT技术网站 - 云狐网

tBv电脑_数码_手机应用问题解决的IT技术网站 - 云狐网

利用自定义页面添加ditu.html,再引用iframetBv电脑_数码_手机应用问题解决的IT技术网站 - 云狐网
 tBv电脑_数码_手机应用问题解决的IT技术网站 - 云狐网

  1. <iframe scrolling="no" src="[!--news.url--]ditu.html"></iframe> 
给iframe定义样式:
  1. iframe { display: block; margin: 30px auto; width: 100%; height: 400px; border: 0; } 
ditu.html参考代码:
  1. <!DOCTYPE html> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3.   <head> 
  4.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  5.     <meta name="keywords" content="百度地图,百度地图API,百度地图自定义工具,百度地图所见即所得工具" /> 
  6.     <meta name="description" content="百度地图API自定义地图,帮助用户在可视化操作下生成百度地图" /> 
  7.     <title>百度地图API自定义地图</title> 
  8.     <!--引用百度地图API--> 
  9.     <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=授权码"></script> 
  10.   </head> 
  11.   <body> 
  12.     <!--百度地图容器--> 
  13. <div style="width:100%;height:400px;border:#ccc solid 1px;" id="map"></div> 
  14.   </body> 
  15.     <script type="text/javascript"> 
  16.         var cp_title="XX有限公司"
  17.         var cp_content="电话:123-456-789<br/>地址:XXXX16号"
  18.         var cp_lng=114.08607; 
  19.         var cp_lat=22.995141;  
  20.         //创建和初始化地图函数: 
  21.         function initMap(){ 
  22.             createMap();//创建地图 
  23.             setMapEvent();//设置地图事件 
  24.             addMapControl();//向地图添加控件 
  25.             addMapOverlay();//向地图添加覆盖物 
  26.         } 
  27.         function createMap(){ 
  28.             map = new BMap.Map("map"); 
  29.             map.centerAndZoom(new BMap.Point(cp_lng,cp_lat),19); 
  30.         } 
  31.         function setMapEvent(){ 
  32.             map.enableScrollWheelZoom(); 
  33.             map.enableKeyboard(); 
  34.             map.enableDragging(); 
  35.             map.enableDoubleClickZoom() 
  36.         } 
  37.         function addClickHandler(target,window){ 
  38.             target.addEventListener("click",function(){ 
  39.                 target.openInfoWindow(window); 
  40.             }); 
  41.         } 
  42.         function addMapOverlay(){ 
  43.             var markers = [ 
  44.                 {content:cp_content,title:cp_title,imageOffset: {width:-46,height:-21},position:{lat:cp_lat,lng:cp_lng}} 
  45.             ]; 
  46.             for(var index = 0; index < markers.length; index++ ){ 
  47.                 var point = new BMap.Point(markers[index].position.lng,markers[index].position.lat); 
  48.                 var marker = new BMap.Marker(point,{icon:new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png",new BMap.Size(20,25),{ 
  49.                         imageOffset: new BMap.Size(markers[index].imageOffset.width,markers[index].imageOffset.height) 
  50.                     })}); 
  51.                 var label = new BMap.Label(markers[index].title,{offset: new BMap.Size(25,5)}); 
  52.                 var opts = { 
  53.                     width: 200, 
  54.                     title: markers[index].title, 
  55.                     enableMessage: false 
  56.                 }; 
  57.                 var infoWindow = new BMap.InfoWindow(markers[index].content,opts);// 创建信息窗口对象 
  58.                 marker.setLabel(label); 
  59.                 addClickHandler(marker,infoWindow); 
  60.                 map.addOverlay(marker); 
  61.                 map.openInfoWindow(infoWindow, map.getCenter());      // 打开信息窗口 
  62.             }; 
  63.         } 
  64.         //向地图添加控件 
  65.         function addMapControl(){ 
  66.             var scaleControl = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT}); 
  67.             scaleControl.setUnit(BMAP_UNIT_IMPERIAL); 
  68.             map.addControl(scaleControl); 
  69.             var navControl = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE}); 
  70.             map.addControl(navControl); 
  71.             var overviewControl = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:true}); 
  72.             map.addControl(overviewControl); 
  73.         } 
  74.         var map; 
  75.         initMap(); 
  76. </script> 
  77. <style> 
  78. .BMap_bubble_content {  font-size: 13px;} 
  79. .BMap_bubble_title { font-weight: bold; margin-bottom: 8px;} 
  80. label.BMapLabel { display: none !important;} 
  81. </style> 
  82. </html> 
以上就是关于中"帝国cms添加百度API地图,默认显示提示框"的全部内容,如果有遇到其他问题tBv电脑_数码_手机应用问题解决的IT技术网站 - 云狐网
转载来源于"青青模板网"tBv电脑_数码_手机应用问题解决的IT技术网站 - 云狐网