first commit
This commit is contained in:
79
public/static/js/tinymce/plugins/bdmap/bd.html
Normal file
79
public/static/js/tinymce/plugins/bdmap/bd.html
Normal file
@@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>百度地图API自定义地图</title>
|
||||
<style>
|
||||
html,body{margin:0;padding:0;}
|
||||
.iw_poi_title {color:#CC5522;font-size:14px;font-weight:bold;overflow:hidden;padding-right:13px;white-space:nowrap}
|
||||
.iw_poi_content {font:12px arial,sans-serif;overflow:visible;padding-top:4px;white-space:-moz-pre-wrap;word-wrap:break-word}
|
||||
</style>
|
||||
<script src="//api.map.baidu.com/api?key=&v=1.1&services=true"></script>
|
||||
</head>
|
||||
|
||||
<body onload="initMap();">
|
||||
<!--百度地图容器-->
|
||||
<div style="width:697px;height:550px;border:#ccc solid 1px;" id="dituContent"></div>
|
||||
</body>
|
||||
<script>
|
||||
function getParam(name) {
|
||||
return location.href.match(new RegExp('[?&]' + name + '=([^?&]+)', 'i')) ? decodeURIComponent(RegExp.$1) : '';
|
||||
}
|
||||
var centerParam = getParam('center');
|
||||
var zoomParam = getParam('zoom');
|
||||
var widthParam = getParam('width');
|
||||
var heightParam = getParam('height');
|
||||
var markersParam = getParam('center');
|
||||
|
||||
//创建和初始化地图函数:
|
||||
function initMap(){
|
||||
// [FF]切换模式后报错
|
||||
if (!window.BMap) {
|
||||
return;
|
||||
}
|
||||
var dituContent = document.getElementById('dituContent');
|
||||
dituContent.style.width = widthParam + 'px';
|
||||
dituContent.style.height = heightParam + 'px';
|
||||
|
||||
createMap();//创建地图
|
||||
setMapEvent();//设置地图事件
|
||||
addMapControl();//向地图添加控件
|
||||
|
||||
// 创建标注
|
||||
var markersArr = markersParam.split(',');
|
||||
var point = new BMap.Point(markersArr[0], markersArr[1]);
|
||||
var marker = new BMap.Marker(point);
|
||||
map.addOverlay(marker); // 将标注添加到地图中
|
||||
}
|
||||
|
||||
//创建地图函数:
|
||||
function createMap(){
|
||||
var map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
|
||||
var centerArr = centerParam.split(',');
|
||||
var point = new BMap.Point(centerArr[0], centerArr[1]);//定义一个中心点坐标
|
||||
map.centerAndZoom(point, zoomParam);//设定地图的中心点和坐标并将地图显示在地图容器中
|
||||
window.map = map;//将map变量存储在全局
|
||||
}
|
||||
|
||||
//地图事件设置函数:
|
||||
function setMapEvent(){
|
||||
map.enableDragging();//启用地图拖拽事件,默认启用(可不写)
|
||||
//map.enableScrollWheelZoom();//启用地图滚轮放大缩小
|
||||
map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写)
|
||||
map.enableKeyboard();//启用键盘上下左右键移动地图
|
||||
}
|
||||
|
||||
//地图控件添加函数:
|
||||
function addMapControl(){
|
||||
//向地图中添加缩放控件
|
||||
var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
|
||||
map.addControl(ctrl_nav);
|
||||
//向地图中添加缩略图控件
|
||||
//var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
|
||||
//map.addControl(ctrl_ove);
|
||||
//向地图中添加比例尺控件
|
||||
var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
|
||||
map.addControl(ctrl_sca);
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
124
public/static/js/tinymce/plugins/bdmap/map.html
Normal file
124
public/static/js/tinymce/plugins/bdmap/map.html
Normal file
@@ -0,0 +1,124 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Baidu Maps</title>
|
||||
<style>
|
||||
html { height:100%; }
|
||||
body { height:100%;margin:0;padding:0;background-color:#fff; }
|
||||
#search_box{position:fixed;top:5px;right:5px;z-index:9999;}
|
||||
#search_box input{
|
||||
-webkit-appearance: none;
|
||||
border-radius:3px;
|
||||
box-sizing:border-box;
|
||||
outline:0;
|
||||
box-shadow:0 0 3px rgba(0,0,0,0.4);
|
||||
}
|
||||
#search_box input[type="text"]{
|
||||
background-color:#fff;
|
||||
border:1px solid #ccc;
|
||||
color:#000;
|
||||
width:180px;
|
||||
padding:5px;
|
||||
font-size:16px;
|
||||
opacity:0.7;
|
||||
box-shadow:0 0 3px rgba(0,0,0,0.4);
|
||||
}
|
||||
#search_box input[type="button"]{
|
||||
margin-left:5px;
|
||||
background-color:#207ab7;
|
||||
border:1px solid #207ab7;
|
||||
color:#fff;
|
||||
padding:4px 6px;
|
||||
font-size:14px;
|
||||
}
|
||||
</style>
|
||||
<script charset="utf-8" src="//api.map.baidu.com/api?v=3.0&ak=ONwdanPtvCDLHBSm184T2ynP"></script>
|
||||
<script>
|
||||
var editor=parent.tinymce.activeEditor;
|
||||
function insCnt(txt){
|
||||
editor.insertContent(txt);
|
||||
parent.tinymce.activeEditor.windowManager.close();
|
||||
}
|
||||
|
||||
var map, geocoder;
|
||||
var lng,lat;
|
||||
function initialize() {
|
||||
map = new BMap.Map('map_canvas');
|
||||
var point = new BMap.Point(116.331398,39.897445);
|
||||
map.centerAndZoom(point, 14);
|
||||
map.addControl(new BMap.NavigationControl());
|
||||
//map.enableScrollWheelZoom();
|
||||
|
||||
//根据IP定位
|
||||
var myCity = new BMap.LocalCity();
|
||||
myCity.get(function(result){map.setCenter(result.name);});
|
||||
|
||||
//浏览器定位,位置更准确,但需要弹出确认,扰民弃用
|
||||
/*var gl = new BMap.Geolocation();
|
||||
gl.getCurrentPosition(function(r){
|
||||
if(this.getStatus() == BMAP_STATUS_SUCCESS){
|
||||
var mk = new BMap.Marker(r.point);
|
||||
map.addOverlay(mk);
|
||||
map.panTo(r.point);
|
||||
}else {
|
||||
//alert('failed'+this.getStatus());
|
||||
}
|
||||
},{enableHighAccuracy: true})*/
|
||||
|
||||
var gc = new BMap.Geocoder();
|
||||
gc.getLocation(point, function(rs){
|
||||
var addComp = rs.addressComponents;
|
||||
var address = [addComp.city].join('');
|
||||
//console.log(address);
|
||||
});
|
||||
|
||||
map.addEventListener('click',function(e){
|
||||
//alert(e.point.lng + "," + e.point.lat);
|
||||
lng=e.point.lng;
|
||||
lat=e.point.lat;
|
||||
var marker = new BMap.Marker(new BMap.Point(e.point.lng, e.point.lat));
|
||||
map.clearOverlays();
|
||||
map.addOverlay(marker);
|
||||
//insCnt(lng+','+lat);
|
||||
parent.tinymceLng=lng;
|
||||
parent.tinymceLat=lat;
|
||||
});
|
||||
|
||||
document.getElementById('kw').addEventListener('keypress',function(e){
|
||||
if(e.keyCode=='13'){
|
||||
e.preventDefault();
|
||||
searchByStationName();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function searchByStationName() {
|
||||
var localSearch = new BMap.LocalSearch(map);
|
||||
//localSearch.enableAutoViewport(); //允许自动调节窗体大小
|
||||
map.clearOverlays();//清空原来的标注
|
||||
var keyword = document.getElementById("kw").value;
|
||||
localSearch.setSearchCompleteCallback(function (searchResult) {
|
||||
console.log(searchResult);
|
||||
if(searchResult.Br.length==0){
|
||||
alert('搜索不到该地区');
|
||||
return false;
|
||||
}
|
||||
var poi = searchResult.Br[0];
|
||||
map.centerAndZoom(poi.point, 14);
|
||||
var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat));
|
||||
parent.tinymceLng=poi.point.lng;
|
||||
parent.tinymceLat=poi.point.lat;
|
||||
map.addOverlay(marker);
|
||||
});
|
||||
localSearch.search(keyword);
|
||||
return false;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="initialize();">
|
||||
<div id="search_box"><input id="kw" type="text" value="" autocomplete="off" placeholder="输入要搜索的地点" /><input type="button" value="搜索" onclick="searchByStationName()"></div>
|
||||
<div id="map_canvas" style="width:100%; height:100%"></div>
|
||||
</body>
|
||||
</html>
|
||||
70
public/static/js/tinymce/plugins/bdmap/plugin.js
Normal file
70
public/static/js/tinymce/plugins/bdmap/plugin.js
Normal file
@@ -0,0 +1,70 @@
|
||||
tinymce.PluginManager.add('bdmap', function(editor, url) {
|
||||
var pluginName='插入百度地图';
|
||||
var baseURL=tinymce.baseURL;
|
||||
var iframe1 = baseURL+'/plugins/bdmap/map.html';
|
||||
var bdmap_width = function (editor) {
|
||||
return editor.getParam('bdmap_width', 560);
|
||||
};
|
||||
var bdmap_height = function (editor) {
|
||||
return editor.getParam('bdmap_height', 362);
|
||||
};
|
||||
window.tinymceLng='';
|
||||
window.tinymceLat='';
|
||||
var openDialog = function() {
|
||||
return editor.windowManager.openUrl({
|
||||
title: pluginName,
|
||||
size: 'large',
|
||||
url:iframe1,
|
||||
buttons: [
|
||||
{
|
||||
type: 'cancel',
|
||||
text: 'Close'
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
text: 'Save',
|
||||
name: 'save',
|
||||
primary: true
|
||||
},
|
||||
],
|
||||
onAction: function (api, details) {
|
||||
switch (details.name) {
|
||||
case 'save':
|
||||
html='<iframe src="'+baseURL+'/plugins/bdmap/bd.html?center='+tinymceLng+'%2C'+tinymceLat+'&zoom=14&width='+(bdmap_width(editor)-2)+'&height='+(bdmap_height(editor)-2)+'" frameborder="0" style="width:'+bdmap_width(editor)+'px;height:'+bdmap_height(editor)+'px;">';
|
||||
editor.insertContent(html);
|
||||
api.close();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
editor.ui.registry.getAll().icons.bdmap || editor.ui.registry.addIcon('bdmap','<?xml version="1.0" encoding="UTF-8"?><svg width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M9.85786 32.7574C6.23858 33.8432 4 35.3432 4 37C4 40.3137 12.9543 43 24 43V43C35.0457 43 44 40.3137 44 37C44 35.3432 41.7614 33.8432 38.1421 32.7574" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M24 35C24 35 37 26.504 37 16.6818C37 9.67784 31.1797 4 24 4C16.8203 4 11 9.67784 11 16.6818C11 26.504 24 35 24 35Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M24 22C26.7614 22 29 19.7614 29 17C29 14.2386 26.7614 12 24 12C21.2386 12 19 14.2386 19 17C19 19.7614 21.2386 22 24 22Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/></svg>');
|
||||
|
||||
editor.ui.registry.addButton('bdmap', {
|
||||
icon: 'bdmap',
|
||||
tooltip: pluginName,
|
||||
onAction: function() {
|
||||
openDialog();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
editor.ui.registry.addMenuItem('bdmap', {
|
||||
text: pluginName,
|
||||
onAction: function() {
|
||||
openDialog();
|
||||
}
|
||||
});
|
||||
return {
|
||||
getMetadata: function() {
|
||||
return {
|
||||
name: pluginName,
|
||||
url: "http://tinymce.ax-z.cn/more-plugins/bdmap.php",
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
70
public/static/js/tinymce/plugins/bdmap/plugin.min.js
vendored
Normal file
70
public/static/js/tinymce/plugins/bdmap/plugin.min.js
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
tinymce.PluginManager.add('bdmap', function(editor, url) {
|
||||
var pluginName='插入百度地图';
|
||||
var baseURL=tinymce.baseURL;
|
||||
var iframe1 = baseURL+'/plugins/bdmap/map.html';
|
||||
var bdmap_width = function (editor) {
|
||||
return editor.getParam('bdmap_width', 560);
|
||||
};
|
||||
var bdmap_height = function (editor) {
|
||||
return editor.getParam('bdmap_height', 362);
|
||||
};
|
||||
window.tinymceLng='';
|
||||
window.tinymceLat='';
|
||||
var openDialog = function() {
|
||||
return editor.windowManager.openUrl({
|
||||
title: pluginName,
|
||||
size: 'large',
|
||||
//width: 800,
|
||||
//height: 500,
|
||||
url:iframe1,
|
||||
buttons: [
|
||||
{
|
||||
type: 'cancel',
|
||||
text: 'Close'
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
text: 'Save',
|
||||
name: 'save',
|
||||
primary: true
|
||||
},
|
||||
],
|
||||
onAction: function (api, details) {
|
||||
switch (details.name) {
|
||||
case 'save':
|
||||
html='<iframe src="'+baseURL+'/plugins/bdmap/bd.html?center='+tinymceLng+'%2C'+tinymceLat+'&zoom=14&width='+(bdmap_width(editor)-2)+'&height='+(bdmap_height(editor)-2)+'" frameborder="0" style="width:'+bdmap_width(editor)+'px;height:'+bdmap_height(editor)+'px;">';
|
||||
editor.insertContent(html);
|
||||
api.close();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
editor.ui.registry.getAll().icons.bdmap || editor.ui.registry.addIcon('bdmap','<?xml version="1.0" encoding="UTF-8"?><svg width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M9.85786 32.7574C6.23858 33.8432 4 35.3432 4 37C4 40.3137 12.9543 43 24 43V43C35.0457 43 44 40.3137 44 37C44 35.3432 41.7614 33.8432 38.1421 32.7574" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M24 35C24 35 37 26.504 37 16.6818C37 9.67784 31.1797 4 24 4C16.8203 4 11 9.67784 11 16.6818C11 26.504 24 35 24 35Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/><path d="M24 22C26.7614 22 29 19.7614 29 17C29 14.2386 26.7614 12 24 12C21.2386 12 19 14.2386 19 17C19 19.7614 21.2386 22 24 22Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/></svg>');
|
||||
|
||||
editor.ui.registry.addButton('bdmap', {
|
||||
icon: 'bdmap',
|
||||
tooltip: pluginName,
|
||||
onAction: function() {
|
||||
openDialog();
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addMenuItem('bdmap', {
|
||||
text: pluginName,
|
||||
onAction: function() {
|
||||
openDialog();
|
||||
}
|
||||
});
|
||||
return {
|
||||
getMetadata: function() {
|
||||
return {
|
||||
name: pluginName,
|
||||
url: "http://tinymce.ax-z.cn/more-plugins/bdmap.php",
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user