リビジョン | e40a8e06799300b31f2e68a3a1eef300846228ee (tree) |
---|---|
日時 | 2017-02-27 14:28:13 |
作者 | naoki hirata <naoki@magi...> |
コミッター | naoki hirata |
CKEditorのGoogleマッププラグイン更新。
@@ -7,7 +7,7 @@ | ||
7 | 7 | * |
8 | 8 | * @package Magic3 Framework |
9 | 9 | * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp> |
10 | - * @copyright Copyright 2006-2016 Magic3 Project. | |
10 | + * @copyright Copyright 2006-2017 Magic3 Project. | |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GPL License |
12 | 12 | * @version 1.3 |
13 | 13 | * @link http://www.magic3.org |
@@ -71,7 +71,7 @@ var GoogleMap = function() | ||
71 | 71 | this.mapType = 0; |
72 | 72 | } |
73 | 73 | |
74 | -GoogleMap.prototype.generateStaticMap = function() | |
74 | +GoogleMap.prototype.generateStaticMap = function(apiKey) | |
75 | 75 | { |
76 | 76 | var w = Math.min(this.width, 640); |
77 | 77 | var h = Math.min(this.height, 640); |
@@ -80,14 +80,8 @@ GoogleMap.prototype.generateStaticMap = function() | ||
80 | 80 | |
81 | 81 | var staticMapTypes = ['roadmap', 'satellite', 'hybrid', 'terrain']; |
82 | 82 | |
83 | -// var mapUrl = 'http://maps.google.com/maps/api/staticmap?center=' + this.centerLat + ',' + this.centerLon | |
84 | 83 | var mapUrl = 'https://maps.googleapis.com/maps/api/staticmap?'; |
85 | -// if (M3_GOOGLEMAPS_KEY) mapUrl += 'key=' + M3_GOOGLEMAPS_KEY + '&'; | |
86 | - if (typeof(M3_GOOGLEMAPS_KEY) === "undefined"){ | |
87 | - alert('Googleマップを表示するにはAPIキーの設定が必要です'); | |
88 | - } else { | |
89 | - mapUrl += 'key=' + M3_GOOGLEMAPS_KEY + '&'; | |
90 | - } | |
84 | + if (apiKey) mapUrl += 'key=' + apiKey + '&'; | |
91 | 85 | |
92 | 86 | mapUrl += 'center=' + this.centerLat + ',' + this.centerLon |
93 | 87 | + '&zoom=' + this.zoom + '&size=' + w + 'x' + h |
@@ -7,7 +7,7 @@ | ||
7 | 7 | * |
8 | 8 | * @package Magic3 Framework |
9 | 9 | * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp> |
10 | - * @copyright Copyright 2006-2014 Magic3 Project. | |
10 | + * @copyright Copyright 2006-2017 Magic3 Project. | |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GPL License |
12 | 12 | * @version 1.2 |
13 | 13 | * @link http://www.magic3.org |
@@ -28,8 +28,19 @@ | ||
28 | 28 | var fakeImage; |
29 | 29 | var infoWindow; |
30 | 30 | var polyline; |
31 | + var apiKey = ''; | |
31 | 32 | // var inLoading; |
32 | 33 | |
34 | + // GoogleMapsAPIキーが設定されているかチェック | |
35 | + if (typeof(editor.config.googlemapsPlugin) === "undefined" || typeof(editor.config.googlemapsPlugin.apiKey) === "undefined"){ | |
36 | + alert(editor.lang.googlemaps.msgApiKeyNotConfigured); | |
37 | + } else { | |
38 | + apiKey = editor.config.googlemapsPlugin.apiKey; | |
39 | + } | |
40 | + | |
41 | + // GoogleMapsAPIが読み込まれていない場合は読み込む | |
42 | + if (typeof(google) === "undefined") $.getScript("https://maps.googleapis.com/maps/api/js?key=" + apiKey); | |
43 | + | |
33 | 44 | // スクリプト読み込み |
34 | 45 | var pluginUrl = CKEDITOR.getUrl(CKEDITOR.plugins.getPath( 'googlemaps' )); |
35 | 46 |
@@ -493,7 +504,7 @@ | ||
493 | 504 | }); |
494 | 505 | |
495 | 506 | // ビュー更新前、画像のみ変更 |
496 | - var extraStyles = { 'background-image': 'url(' + mapInfo.generateStaticMap() + ')', | |
507 | + var extraStyles = { 'background-image': 'url(' + mapInfo.generateStaticMap(apiKey) + ')', | |
497 | 508 | 'background-position': 'center center', |
498 | 509 | 'background-repeat': 'no-repeat', |
499 | 510 | 'border': '0px', |
@@ -7,7 +7,7 @@ | ||
7 | 7 | * |
8 | 8 | * @package Magic3 Framework |
9 | 9 | * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp> |
10 | - * @copyright Copyright 2006-2014 Magic3 Project. | |
10 | + * @copyright Copyright 2006-2017 Magic3 Project. | |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GPL License |
12 | 12 | * @version 1.0 |
13 | 13 | * @link http://www.magic3.org |
@@ -42,5 +42,6 @@ CKEDITOR.plugins.setLang( 'googlemaps', 'en', { | ||
42 | 42 | mapType: 'Map Type', |
43 | 43 | msgDefaultMarkerText: 'Input text.', |
44 | 44 | msgInputStyleJsonData: 'Input style data by JSON format.', |
45 | - msgInvalidStyle: 'Invalid JSON data.' | |
45 | + msgInvalidStyle: 'Invalid JSON data.', | |
46 | + msgApiKeyNotConfigured: 'Google Maps API key not configured.' | |
46 | 47 | }); |
@@ -7,7 +7,7 @@ | ||
7 | 7 | * |
8 | 8 | * @package Magic3 Framework |
9 | 9 | * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp> |
10 | - * @copyright Copyright 2006-2014 Magic3 Project. | |
10 | + * @copyright Copyright 2006-2017 Magic3 Project. | |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GPL License |
12 | 12 | * @version 1.0 |
13 | 13 | * @link http://www.magic3.org |
@@ -55,5 +55,6 @@ CKEDITOR.plugins.setLang( 'googlemaps', 'ja', { | ||
55 | 55 | line: 'ライン', |
56 | 56 | msgLineInstruction: 'クリックするとポイントが追加されます。<br />ポイントはドラッグすることもDELキーで削除することもできます。', |
57 | 57 | msgInputStyleJsonData: 'JSONフォーマットのスタイルデータを入力してください。', |
58 | - msgInvalidStyle: '無効なJSONデータです。' | |
58 | + msgInvalidStyle: '無効なJSONデータです。', | |
59 | + msgApiKeyNotConfigured: 'GoogleマップAPIキーが設定されていません。' | |
59 | 60 | }); |
@@ -7,7 +7,7 @@ | ||
7 | 7 | * |
8 | 8 | * @package Magic3 Framework |
9 | 9 | * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp> |
10 | - * @copyright Copyright 2006-2014 Magic3 Project. | |
10 | + * @copyright Copyright 2006-2017 Magic3 Project. | |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GPL License |
12 | 12 | * @version 1.2 |
13 | 13 | * @link http://www.magic3.org |
@@ -51,6 +51,13 @@ | ||
51 | 51 | }, |
52 | 52 | // 初期起動時、ソースモード切替時に呼び出し |
53 | 53 | afterInit: function(editor){ |
54 | + var apiKey = ''; | |
55 | + if (typeof(editor.config.googlemapsPlugin) === "undefined" || typeof(editor.config.googlemapsPlugin.apiKey) === "undefined"){ | |
56 | + alert(editor.lang.googlemaps.msgApiKeyNotConfigured); | |
57 | + } else { | |
58 | + apiKey = editor.config.googlemapsPlugin.apiKey; | |
59 | + } | |
60 | + | |
54 | 61 | // SCRIPTタグのGoogleマップ情報読み込み |
55 | 62 | var div = document.createElement('div'); |
56 | 63 | div.innerHTML = editor.getData(); |
@@ -113,7 +120,7 @@ | ||
113 | 120 | CKEDITOR.addCss( |
114 | 121 | 'img.cke_googlemaps' + mapNumber + |
115 | 122 | '{' + |
116 | - 'background-image: url(' + mapInfo.generateStaticMap() + ');' + | |
123 | + 'background-image: url(' + mapInfo.generateStaticMap(apiKey) + ');' + | |
117 | 124 | 'background-position: center center;' + |
118 | 125 | 'background-repeat: no-repeat;' + |
119 | 126 | 'border: 0px;' + |