ecshop二次开发 百度地图

ecshop二次开发 百度地图

1.  在ecshop后台找到文章管理->文章分类->添加文章分类,添加一个顶级分类,叫做“合作单位”,并且让其显示在导航栏

2. .在ecshop后台找到文章管理->文章列表->添加新文章。(文章标题:八维研修学院;文章分类:合作单位;文章重要性:普通;是否显示:是,等等一些东西完善了)

3.ecshop/languages/zh_cn/admin/article.php   在第56行 添加   $_LANG['baidu_map'] = '百度地图';

4.ecshop/admin/templates/article_info.htm    在

<span class="tab-back" id="goods-tab">{$lang.tab_goods}</span>

之后添加
<span class="tab-back" id="baidu-tab">{$lang.baidu_map}</span>   

展示效果:

ecshop后台文章管理->文章列表->编辑文章内容,可以看到导航标签多了一个百度地图


5. 在 ecshop/admin/templates/article_info.htm中 在
<form  action="article.php" method="post" enctype="multipart/form-data" name="theForm" οnsubmit="return validate();">

之后添加
<table width="90%" id="baidu-table" style="display: none">
                <tr>
                    <td class="narrow-label">{$lang.baidu_map_info}</td>
                    <td><input type="text" name="point_x" size ="20" maxlength="30" value="{$article.point_x|escape}" />,<input type="text" name="point_y" size ="20" maxlength="30" value="{$article.point_y|escape}" />{$lang.require_field}</td>
                </tr>
            </table>

6..在ecs.article表中添加两个字段:point_x、point_y,都是varchar类型

7.在ecshop/admin/article.php里面搜索“插入数据” 把$sql替换成
 $sql = "INSERT INTO ".$ecs->table('article')."(title, cat_id, article_type, is_open, author, "."author_email, keywords, content, add_time, file_url, open_type, link, description,point_x,point_y) "."VALUES ('$_POST[title]', '$_POST[article_cat]', '$_POST[article_type]', '$_POST[is_open]', "."'$_POST[author]', '$_POST[author_email]', '$_POST[keywords]', '$_POST[FCKeditor1]', "."'$add_time', '$file_url', '$open_type', '$_POST[link_url]', '$_POST[description]','$_POST[point_x]','$_POST[point_y]')";

         $db->query($sql);


8. ecshop/admin/article.php中找到if ($exc->edit("title='$_POST[title]'一段
替换成
:

         if ($exc->edit("title='$_POST[title]', cat_id='$_POST[article_cat]', article_type='$_POST[article_type]', is_open='$_POST[is_open]', author='$_POST[author]', author_email='$_POST[author_email]', keywords ='$_POST[keywords]', file_url ='$file_url', open_type='$open_type', content='$_POST[FCKeditor1]', link='$_POST[link_url]', description = '$_POST[description]',point_x = '$_POST[point_x]',point_y = '$_POST[point_y]'", $_POST['id']))


9.在百度地图坐标文本框输入:116.46;39.92 (分别为经纬度)

10.ecshop/upload/article.php找到
if(isset($article) && $article['cat_id'] > 2) 替换<pre name="code" class="python">if(isset($article) && $article['cat_id'] > 2)
{
    if($article['cat_id']==13){

        $smarty->display('article_company.dwt', $cache_id);

    }else{

        $smarty->display('article.dwt', $cache_id);

    }


    // $smarty->display('article.dwt', $cache_id);
}



11..在\ecshop\themes\default里面复制article_pro.dwt改名为article_company.dwt 下列话添到
<link href="{$ecs_css_path}" rel="stylesheet" type="text/css" />
之后
<style type="text/css">

                   #allmap{width:100%;height:500px;}

         </style>
        {*  ak可以用自己在百度上的秘钥*}
         <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=KBKXQwI8M5CdH44DbDfNORa9D11WYUG2"></script>

12.在
 {$article.content}
     <!-- {/if} -->
之后添加
<pre name="code" class="python"> <div id="allmap"></div>
     <script type="text/javascript">

         // 百度地图API功能

         var sContent =

     "<h4 style='margin:0 0 5px 0;padding:0.2em 0'>{$article.title|escape:html}</h4>" +

     "<img style='float:right;margin:4px' id='imgDemo' src='{$article.file_url}' width='139' height='104' title='{$article.title|escape:html}'/>" +

     "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>{$article.description}</p>" +

     "</div>";

         var map = new BMap.Map("allmap");

         var point = new BMap.Point({$article.point_x},{$article.point_y});

         var marker = new BMap.Marker(point);

         var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象

         map.centerAndZoom(point, 15);

         map.addOverlay(marker);

         marker.addEventListener("click", function(){

             this.openInfoWindow(infoWindow);

             //图片加载完毕重绘infowindow

             document.getElementById('imgDemo').onload = function (){

                 infoWindow.redraw();   //防止在网速较慢,图片未加载时,生成的信息框高度比图片的总高度小,导致图片部分被隐藏

   }

     });

  </script>







 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值