主题: 百度官方地图代码问题,已自己解决
作者: 丰收之歌, 发布日期: 2013-04-10 11:23:36, 浏览数: 2428
操作系统:

浏览器版本:

KindEditor版本:
4.16
BUG再现步骤:
1.粘贴该段代码到编辑器后:var iw = new BMap.InfoWindow("<b class='iw_poi_title' title='" + json.title + "'>" + json.title + "</b><div class='iw_poi_content'>"+json.content+"</div>");
2.代码中的'单引号全部变为双引号或者&quot; 导致百度动态地图无法使用
期望结果:
期望使用百度动态地图代码进行测试
作者: 丰收之歌, 发布日期: 2013-04-12 11:45:48

自己解决了

贴代码:

 function addEvent(obj, evt, fn) {
            if (document.all) {
                obj.attachEvent("on" + evt, function () {
                    fn.call(obj, window.event)
                });

            }
            else {
                obj.addEventListener(evt, fn, false);
            }
        }

 KindEditor.ready(function (K) {
            editor = K.create('textarea[name="content1"]', {
                filterMode: false,
                cssPath: '/Manage/js/kindeditor/plugins/code/prettify.css',
                uploadJson: '/Manage/Server/UpMorePic.aspx?cmd=editor&wsid=<%=wsID%>&token=<%=token%>', ///Manage/js/kindeditor/asp.net/upload_json.ashx
                fileManagerJson: '/Manage/js/kindeditor/asp.net/file_manager_json.ashx?wsid=<%=wsID%>&token=<%=token%>',
                allowFileManager: true,
                items: keExtend.items
            });
            addEvent(document.forms[0], "submit", function () {//对百度地图代码进行处理
                var v = document.getElementById("content1").value;
                if (v.indexOf("//创建InfoWindow") != -1) {
                    var sIndex = v.indexOf("//创建InfoWindow");
                    var eIndex = v.indexOf("//创建一个Icon");
                    var sStr = v.substring(0, sIndex);
                    var eStr = v.substring(eIndex, v.length - 1);
                    v = sStr + "\/\/创建InfoWindow\n";
                    v += "function createInfoWindow(i){\n";
                    v += "var json = markerArr[i];\n";
                    v += "var iw = new BMap.InfoWindow(\"<b class='iw_poi_title' title='\" + json.title + \"'>\" + json.title + \"</b><div class='iw_poi_content'>\"+json.content+\"</div>\");\n";
                    v += "return iw;\n";
                    v += "}\n";
                    v += eStr;
                    document.getElementById("content1").value = v;
                }
            });
        });

回复
发表新帖 发表回复