OSDN Git Service

CKEditorのGoogleマッププラグイン更新。
authornaoki hirata <naoki@magic3.org>
Mon, 27 Feb 2017 05:28:13 +0000 (14:28 +0900)
committernaoki hirata <naoki@magic3.org>
Mon, 27 Feb 2017 05:28:13 +0000 (14:28 +0900)
scripts/ckeditor4.6.2/plugins/googlemaps/dialogs/googlemaps.js
scripts/ckeditor4.6.2/plugins/googlemaps/dialogs/main.js
scripts/ckeditor4.6.2/plugins/googlemaps/lang/en.js
scripts/ckeditor4.6.2/plugins/googlemaps/lang/ja.js
scripts/ckeditor4.6.2/plugins/googlemaps/plugin.js

index fe76126..cabd124 100644 (file)
@@ -7,7 +7,7 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2016 Magic3 Project.
+ * @copyright  Copyright 2006-2017 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version    1.3
  * @link       http://www.magic3.org
@@ -71,7 +71,7 @@ var GoogleMap = function()
        this.mapType = 0;
 }
 
-GoogleMap.prototype.generateStaticMap = function()
+GoogleMap.prototype.generateStaticMap = function(apiKey)
 {
        var w = Math.min(this.width, 640);
        var h = Math.min(this.height, 640);
@@ -80,14 +80,8 @@ GoogleMap.prototype.generateStaticMap = function()
        
        var staticMapTypes = ['roadmap', 'satellite', 'hybrid', 'terrain'];
 
-//     var mapUrl = 'http://maps.google.com/maps/api/staticmap?center=' + this.centerLat + ',' + this.centerLon 
        var mapUrl = 'https://maps.googleapis.com/maps/api/staticmap?';
-//     if (M3_GOOGLEMAPS_KEY) mapUrl += 'key=' + M3_GOOGLEMAPS_KEY + '&';
-       if (typeof(M3_GOOGLEMAPS_KEY) === "undefined"){
-               alert('Googleマップを表示するにはAPIキーの設定が必要です');
-       } else {
-               mapUrl += 'key=' + M3_GOOGLEMAPS_KEY + '&';
-       }
+       if (apiKey) mapUrl += 'key=' + apiKey + '&';
 
        mapUrl  += 'center=' + this.centerLat + ',' + this.centerLon 
                                + '&zoom=' + this.zoom + '&size=' + w + 'x' + h 
index 7eef0bd..6573346 100644 (file)
@@ -7,7 +7,7 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2014 Magic3 Project.
+ * @copyright  Copyright 2006-2017 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version    1.2
  * @link       http://www.magic3.org
                var fakeImage;
                var infoWindow;
                var polyline;
+               var apiKey = '';
 //             var inLoading;
                
+               // GoogleMapsAPIキーが設定されているかチェック
+               if (typeof(editor.config.googlemapsPlugin) === "undefined" || typeof(editor.config.googlemapsPlugin.apiKey) === "undefined"){
+                       alert(editor.lang.googlemaps.msgApiKeyNotConfigured);
+               } else {
+                       apiKey = editor.config.googlemapsPlugin.apiKey;
+               }
+                       
+               // GoogleMapsAPIが読み込まれていない場合は読み込む
+               if (typeof(google) === "undefined") $.getScript("https://maps.googleapis.com/maps/api/js?key=" + apiKey);
+               
                // スクリプト読み込み
                var pluginUrl = CKEDITOR.getUrl(CKEDITOR.plugins.getPath( 'googlemaps' ));
                        
                                });
 
                                // ビュー更新前、画像のみ変更
-                               var extraStyles = {     'background-image': 'url(' + mapInfo.generateStaticMap() + ')',
+                               var extraStyles = {     'background-image': 'url(' + mapInfo.generateStaticMap(apiKey) + ')',
                                                        'background-position': 'center center',
                                                        'background-repeat': 'no-repeat',
                                                        'border': '0px',
index 275eb27..9a431b3 100644 (file)
@@ -7,7 +7,7 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2014 Magic3 Project.
+ * @copyright  Copyright 2006-2017 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version    1.0
  * @link       http://www.magic3.org
@@ -42,5 +42,6 @@ CKEDITOR.plugins.setLang( 'googlemaps', 'en', {
        mapType: 'Map Type',
        msgDefaultMarkerText:   'Input text.',
        msgInputStyleJsonData: 'Input style data by JSON format.',
-       msgInvalidStyle: 'Invalid JSON data.'
+       msgInvalidStyle: 'Invalid JSON data.',
+       msgApiKeyNotConfigured: 'Google Maps API key not configured.'
 });
index 4f6b3ac..9cc2778 100644 (file)
@@ -7,7 +7,7 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2014 Magic3 Project.
+ * @copyright  Copyright 2006-2017 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version    1.0
  * @link       http://www.magic3.org
@@ -55,5 +55,6 @@ CKEDITOR.plugins.setLang( 'googlemaps', 'ja', {
        line:   'ライン',
        msgLineInstruction:     'クリックするとポイントが追加されます。<br />ポイントはドラッグすることもDELキーで削除することもできます。',
        msgInputStyleJsonData: 'JSONフォーマットのスタイルデータを入力してください。',
-       msgInvalidStyle: '無効なJSONデータです。'
+       msgInvalidStyle: '無効なJSONデータです。',
+       msgApiKeyNotConfigured: 'GoogleマップAPIキーが設定されていません。'
 });
index bb2ebeb..c9199c7 100644 (file)
@@ -7,7 +7,7 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2014 Magic3 Project.
+ * @copyright  Copyright 2006-2017 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version    1.2
  * @link       http://www.magic3.org
                },
                // 初期起動時、ソースモード切替時に呼び出し
                afterInit: function(editor){
+                       var apiKey = '';
+                       if (typeof(editor.config.googlemapsPlugin) === "undefined" || typeof(editor.config.googlemapsPlugin.apiKey) === "undefined"){
+                               alert(editor.lang.googlemaps.msgApiKeyNotConfigured);
+                       } else {
+                               apiKey = editor.config.googlemapsPlugin.apiKey;
+                       }
+                       
                        // SCRIPTタグのGoogleマップ情報読み込み
                        var div = document.createElement('div');
                        div.innerHTML = editor.getData();
                                                                        CKEDITOR.addCss(
                                                                                'img.cke_googlemaps' + mapNumber +
                                                                                '{' +
-                                                                                       'background-image: url(' + mapInfo.generateStaticMap() + ');' +
+                                                                                       'background-image: url(' + mapInfo.generateStaticMap(apiKey) + ');' +
                                                                                        'background-position: center center;' +
                                                                                        'background-repeat: no-repeat;' +
                                                                                        'border: 0px;' +