文章摘要:解决https协议下无法正常插入动态地图,pbootcms中升级ueditor2.0解决https协议下无法正常插入动态地图,pbootcms中路径,PbootCMS-V3.1.3\core\extend\ueditor\dialogs\map,修改js配置
解决https协议下无法正常插入动态地图
pbootCMS模板支持https
pbootcms中路径
PbootCMS-V3.1.3\core\extend\ueditor\dialogs\map
修改js配置
打开路径
PbootCMS-V3.1.3\core\extend\ueditor
找到该文件ueditor.config.js
查看
whitList 看看是否配置一下内容
a: ['target', 'href', 'title', 'class', 'style']
iframe: ['src', 'class', 'height', 'width', 'max-width', 'max-height', 'align', 'frameborder', 'allowfullscreen','border','marginwidth','marginheight','id']
若存在无视进行下一步
修改map.html
路径
PbootCMS-V3.1.3\core\extend\ueditor\dialogs\map\map.html
将文件中
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.1&services=true"></script>
替换为
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=
4BqRXwK4AFi6bgbrTWfGyUXs7lATsSnC
&s=1"></script>
其中
4BqRXwK4AFi6bgbrTWfGyUXs7lATsSnC为百度地图AK,可自行申请,申请免费
继续找到
dialog.onok = function (){
...
}
该方法按下述修改
dialog.onok = function (){
var center = map.getCenter();
//var zoom = map.zoomLevel; //http协议
var zoom = map.getZoom(); //https协议
var size = map.getSize();
var mapWidth = size.width;
var mapHeight = size.height;
//var point = marker.getPoint(); //http协议
var point = marker.getPosition(); //https协议
if($G('is_dynamic').checked) {
var URL = editor.options.UEDITOR_HOME_URL,
url = [URL + (/\/$/.test(URL) ? '':'/') + "dialogs/map/show.html" +
'#center=' + center.lng + ',' + center.lat,
'&zoom=' + zoom,
'&width=' + mapWidth,
'&height=' + mapHeight,
'&markers=' + point.lng + ',' + point.lat,
'&markerStyles=' + 'l,A'].join('');
editor.execCommand('inserthtml', '<iframe class="ueditor_baidumap" src="' + url + '"' + (styleStr ? ' style="' + styleStr + '"' :'') + ' frameborder="0" width="' + (mapWidth+4) + '" height="' + (mapHeight+4) + '"></iframe>');
} else {
//http协议
//var url = "http://api.map.baidu.com/staticimage?center=" + center.lng + ',' + center.lat +
// "&zoom=" + zoom + "&width=" + size.width + '&height=' + size.height + "&markers=" + point.lng + ',' + point.lat;
//https协议
var url = "https://api.map.baidu.com/staticimage?s=1¢er=" + center.lng + ',' + center.lat +
"&zoom=" + zoom + "&width=" + size.width + '&height=' + size.height + "&markers=" + point.lng + ',' + point.lat;
editor.execCommand('inserthtml', '<img width="'+ size.width +'"height="'+ size.height +'" src="' + url + '"' + (styleStr ? ' style="' + styleStr + '"' :'') + '/>');
}
};
直接复制替换对应方法也可以
还需要替换
marker.setPoint(point);
查到找到上述方法替换成下述内容即可
// marker.setPoint(point); //http协议
marker.setPosition(point); //https协议
相同路径下打开show.html
将
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.1&services=true"></script>
替换为
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=
4BqRXwK4AFi6bgbrTWfGyUXs7lATsSnC
&s=1"></script>
则修改完成
本文采摘于网络,不代表本站立场,转载联系作者并注明出处:https://www.dushilianren.cn/WebsiteNews/299.html