---
title: "Spring boot 环境下配置CKEditor添加google map"
author: "conkeyn"
date: "2017-07-05T14:39:30Z"
tags: []
categories: ["编程语言"]
slug: "spring-boot-ckeditor-google-map"
draft: false
lastmod: "2017-07-05T14:37:37Z"
id: 2382970
url: "https://conkeyn.iteye.com/blog/2382970"
---

本文档基于已经搭建好基础ckeditor的环境上。如：[http://www.cnblogs.com/daxin/p/3553865.html](http://www.cnblogs.com/daxin/p/3553865.html)

使用leaflet的ckeditor的google map插件；

 

1、下载、解压插件

下载地址：

[http://ckeditor.com/addon/leaflet](http://ckeditor.com/addon/leaflet)

下面是leaflet依赖的插件

[http://ckeditor.com/addon/widgetselection](http://ckeditor.com/addon/widgetselection)

[http://ckeditor.com/addon/widget](http://ckeditor.com/addon/widgetselection)

[http://ckeditor.com/addon/lineutils](http://ckeditor.com/addon/lineutils)

将以上包下载，解压到ckeditor/plugins目录下。

 

2、配置ckeditor/config.js

 

```
config.extraPlugins+="widgetselection,lineutils,widget,leaflet,";
config.leaflet_maps_google_api_key = 'AIzaSyA9ySM6msnGm0qQB1L1cLTMBdKEUKPySmQ';
```

 这个google map key建议自己再申请一个哦，代码中的是原开发者的，可能不能用了。

 查看一下效果：

![](http://dl2.iteye.com/upload/attachment/0125/9148/989aa1a6-252a-34d0-b1bf-ce9ce6e60550.png)

3、在java环境中可能会遇到以下错误：

```
in a frame because it set 'x-frame-options' to 'deny'.
```

 4、那么别着急，添加一下java配置代码和xml配置即可。

4.1、使用spring xml文件配置

```
<http>    
    <headers>
        <frame-options policy="SAMEORIGIN"/><!-- 相同域名下允许加载 -->
    </headers>
</http>
```

 

4.2、使用spring boot代码配置

```
@Override
    protected void configure(HttpSecurity http) throws Exception { 
        //直接关闭frameOptions功能
        http.headers().frameOptions().disable();
    }
```

 5、验证一下。