/******************************************************************************* * KindEditor - WYSIWYG HTML Editor for Internet * Copyright (C) 2006-2011 kindsoft.net * * @author Roddy * @site http://www.kindsoft.net/ * @licence http://www.kindsoft.net/license.php *******************************************************************************/ // Google Maps: http://code.google.com/apis/maps/index.html KindEditor.plugin('map', function(K) { var self = this, name = 'map', lang = self.lang(name + '.'); self.clickToolbar(name, function() { var html = ['
', '
', lang.address + ' ', '', '', '', '
', '
', '
'].join(''); var dialog = self.createDialog({ name : name, width : 600, title : self.lang(name), body : html, yesBtn : { name : self.lang('yes'), click : function(e) { var geocoder = win.geocoder, map = win.map, center = map.getCenter().lat() + ',' + map.getCenter().lng(), zoom = map.getZoom(), maptype = map.getMapTypeId(), url = 'http://maps.googleapis.com/maps/api/staticmap'; url += '?center=' + encodeURIComponent(center); url += '&zoom=' + encodeURIComponent(zoom); url += '&size=558x360'; url += '&maptype=' + encodeURIComponent(maptype); url += '&markers=' + encodeURIComponent(center); url += '&language=' + self.langType; url += '&sensor=false'; self.exec('insertimage', url).hideDialog().focus(); } }, beforeRemove : function() { searchBtn.remove(); doc.write(''); iframe.remove(); } }); var div = dialog.div, addressBox = K('[name="address"]', div), searchBtn = K('[name="searchBtn"]', div), win, doc; var iframeHtml = ['', '', '', '', '', '', '', '
', ''].join('\n'); // TODO:用doc.write(iframeHtml)方式加载时,在IE6上第一次加载报错,暂时使用src方式 var iframe = K(''); function ready() { win = iframe[0].contentWindow; doc = K.iframeDoc(iframe); //doc.open(); //doc.write(iframeHtml); //doc.close(); } iframe.bind('load', function() { iframe.unbind('load'); if (K.IE) { ready(); } else { setTimeout(ready, 0); } }); K('.ke-map', div).replaceWith(iframe); // search map searchBtn.click(function() { win.search(addressBox.val()); }); }); });