function plugin_googlemaps2_mark_output($lat, $lng, $params) { global $vars; $qm = get_qm(); if (!defined('PLUGIN_GOOGLEMAPS2_DEF_KEY')) { return $qm->replace('plg_googlemaps2.err_not_called', 'googlemaps2_mark'); } $defoptions = plugin_googlemaps2_mark_get_default(); $inoptions = array(); foreach ($params as $param) { list($index, $value) = split('=', $param); $index = trim($index); $value = htmlspecialchars(trim($value)); $inoptions[$index] = $value; if ($index == 'zoom') { $isSetZoom = true; } //for old api } if (array_key_exists('define', $inoptions)) { $vars['googlemaps2_mark'][$inoptions['define']] = $inoptions; return ""; } $coptions = array(); if (array_key_exists('class', $inoptions)) { $class = $inoptions['class']; if (array_key_exists($class, $vars['googlemaps2_mark'])) { $coptions = $vars['googlemaps2_mark'][$class]; } } // map maxurl to maxcontent if maxurl exists. if (array_key_exists('maxurl', $coptions) && !array_key_exists('maxcontent', $coptions)) { $coptions['maxcontent'] = $coptions['maxurl']; } if (array_key_exists('maxurl', $inoptions) && !array_key_exists('maxcontent', $inoptions)) { $inoptions['maxcontent'] = $inoptions['maxurl']; } $options = array_merge($defoptions, $coptions, $inoptions); $lat = trim($lat); $lng = trim($lng); $title = $options['title']; $caption = $options['caption']; $maxcontent = $options['maxcontent']; $maxtitle = $options['maxtitle']; $image = $options['image']; $icon = $options['icon']; $nolist = plugin_googlemaps2_getbool($options['nolist']); $noinfowindow = plugin_googlemaps2_getbool($options['noinfowindow']); $noicon = plugin_googlemaps2_getbool($options['noicon']); $zoom = $options['zoom']; $maxzoom = (int) $options['maxzoom']; $minzoom = (int) $options['minzoom']; $map = plugin_googlemaps2_addprefix($vars['page'], $options['map']); //XSS対策のため次の二つのオプションはユーザーから設定不可にする。 $formatlist = $defoptions['formatlist']; $formatinfo = $defoptions['formatinfo']; $alink = $options['alink']; $titleispagename = plugin_googlemaps2_getbool($options['titleispagename']); $api = $vars['googlemaps2_info'][$map]['api']; if ($nolist) { $alink = false; } $maxcontentfull = $maxcontent; if ($maxcontent != '') { if (!preg_match('/^http:\\/\\/.*$/i', $maxcontent)) { $encurl = rawurlencode($maxcontent); $maxcontent = get_script_uri(); $maxcontentfull = $maxcontent; $maxcontent .= '?cmd=googlemaps2&action=showbody&page='; $maxcontentfull .= '?'; $maxcontent .= $encurl; $maxcontentfull .= $encurl; } } if ($titleispagename) { $title = $vars['page']; } if ($maxtitle == '') { $maxtitle = $title; } //携帯デバイス用リスト出力 if (!plugin_googlemaps2_is_supported_profile()) { if ($nolist == false) { return plugin_googlemaps_mark_simple_format_listhtml($formatlist, $title, $caption, $maxcontentfull); } return ''; } $page = $vars['page']; if ($api < 2 && $isSetZoom) { $zoom = 19 - $zoom; } if ($zoom == null) { $zoom = 'null'; } if ($noicon == true) { $noinfowindow = true; } //Pukiwikiの添付された画像の表示 $q = '/^http:\\/\\/.*(\\.jpg|\\.gif|\\.png)$/i'; if ($image != '' && !preg_match($q, $image)) { $image = $script . '?plugin=ref' . '&page=' . rawurlencode($vars["page"]) . '&src=' . rawurlencode($image); } if ($noinfowindow == false) { $infohtml = plugin_googlemaps_mark_format_infohtml($map, $formatinfo, $alink, $title, $caption, $image); } else { $infohtml = null; } $key = "{$map},{$lat},{$lng}"; if ($nolist == false) { $listhtml = plugin_googlemaps_mark_format_listhtml($page, $map, $formatlist, $alink, $key, $infohtml, $title, $caption, $image, $zoom, $maxcontentfull); } // Create Marker $output = <<<EOD <script type="text/javascript"> //<![CDATA[ onloadfunc.push(function() { \tp_googlemaps_regist_marker ('{$page}', '{$map}', PGTool.getLatLng({$lat} , {$lng}, '{$api}'), '{$key}', \t{noicon: '{$noicon}', icon:'{$icon}', zoom:{$zoom}, maxzoom:{$maxzoom}, minzoom:{$minzoom}, title:'{$title}', infohtml:'{$infohtml}', maxtitle:'{$maxtitle}', maxcontent:'{$maxcontent}'}); }); //]]> </script> EOD; //Show Markers List if ($nolist == false) { $output .= $listhtml; } return $output; }
function plugin_googlemaps2_output($doInit, $params) { global $vars; $qm = get_qm(); if (!plugin_googlemaps2_is_supported_profile()) { return $qm->m['plg_googlemaps2']['err_unsupport_dev']; } $defoptions = plugin_googlemaps2_get_default(); $inoptions = array(); $isSetZoom = false; foreach ($params as $param) { $pos = strpos($param, '='); if ($pos == false) { continue; } $index = trim(substr($param, 0, $pos)); $value = htmlspecialchars(trim(substr($param, $pos + 1))); $inoptions[$index] = $value; if ($index == 'cx') { $cx = (double) $value; } //for old api if ($index == 'cy') { $cy = (double) $value; } //for old api if ($index == 'zoom') { $isSetZoom = true; } //for old api } if (array_key_exists('define', $inoptions)) { $vars['googlemaps2'][$inoptions['define']] = $inoptions; return ""; } $coptions = array(); if (array_key_exists('class', $inoptions)) { $class = $inoptions['class']; if (array_key_exists($class, $vars['googlemaps2'])) { $coptions = $vars['googlemaps2'][$class]; } } $options = array_merge($defoptions, $coptions, $inoptions); $mapname = plugin_googlemaps2_addprefix($vars['page'], $options['mapname']); $key = $options['key']; $width = $options['width']; $height = $options['height']; $lat = (double) $options['lat']; $lng = (double) $options['lng']; $zoom = (int) $options['zoom']; $mapctrl = $options['mapctrl']; $type = $options['type']; $typectrl = $options['typectrl']; $scalectrl = $options['scalectrl']; $overviewctrl = $options['overviewctrl']; $crossctrl = $options['crossctrl']; $overviewwidth = $options['overviewwidth']; $overviewheight = $options['overviewheight']; $api = (int) $options['api']; $noiconname = $options['noiconname']; $togglemarker = plugin_googlemaps2_getbool($options['togglemarker']); $dbclickzoom = plugin_googlemaps2_getbool($options['dbclickzoom']); $continuouszoom = plugin_googlemaps2_getbool($options['continuouszoom']); $geoxml = preg_replace("/&/i", '&', $options['geoxml']); $googlebar = plugin_googlemaps2_getbool($options['googlebar']); $importicon = $options['importicon']; $backlinkmarker = plugin_googlemaps2_getbool($options['backlinkmarker']); $page = $vars['page']; //apiのチェック if (!(is_numeric($api) && $api >= 0 && $api <= 2)) { $api = 2; } //古い1系APIとの互換性のためcx, cyが渡された場合lng, latに代入する。 if ($api < 2) { if (isset($cx) && isset($cy)) { $lat = $cx; $lng = $cy; } else { $tmp = $lng; $lng = $lat; $lat = $tmp; } } else { if (isset($cx)) { $lng = $cx; } if (isset($cy)) { $lat = $cy; } } // zoomレベル if ($api < 2 && $isSetZoom) { $zoom = 17 - $zoom; } // width, heightの値チェック if (is_numeric($width)) { $width = (int) $width . "px"; } if (is_numeric($height)) { $height = (int) $height . "px"; } // Mapタイプの名前を正規化 $type = plugin_googlemaps2_get_maptype($type); // 初期化処理の出力 if ($doInit) { $output = plugin_googlemaps2_init_output($key, $noiconname); } else { $output = ""; } $pukiwikiname = $options['mapname']; $output .= <<<EOD <div id="{$mapname}" style="width: {$width}; height: {$height};"></div> <script type="text/javascript"> //<![CDATA[ onloadfunc.push( function () { if (typeof(googlemaps_maps['{$page}']) == 'undefined') { \tgooglemaps_maps['{$page}'] = new Array(); \tgooglemaps_markers['{$page}'] = new Array(); \tgooglemaps_marker_mgrs['{$page}'] = new Array(); \tgooglemaps_icons['{$page}'] = new Array(); \tgooglemaps_crossctrl['{$page}'] = new Array(); } var map = new GMap2(document.getElementById("{$mapname}")); map.pukiwikiname = "{$pukiwikiname}"; GEvent.addListener(map, "dblclick", function() { \t\tthis.closeInfoWindow(); }); onloadfunc2.push( function () { \tp_googlemaps_regist_to_markermanager("{$page}", "{$mapname}", true); }); map.setCenter(PGTool.getLatLng({$lat}, {$lng}, "{$api}"), {$zoom}, {$type}); var marker_mgr = new GMarkerManager(map); // 現在(2.70)のMarker Managerではマーカーをhideしていても、描画更新時に // マーカーを表示してしまうため、リフレッシュ後にフラグを確認して再び隠す。 // 一度表示されて消えるみたいな挙動になるが、他に手段が無いので仕方が無い。 GEvent.addListener(marker_mgr, "changed", function(bounds, markerCount) { \tvar markers = googlemaps_markers["{$page}"]["{$mapname}"]; \tfor (key in markers) { \t\tvar m = markers[key]; \t\tif (m.isVisible() == false) { \t\t\tm.marker.hide(); \t\t} \t} }); EOD; // Show Map Control/Zoom switch ($mapctrl) { case "small": $output .= "map.addControl(new GSmallMapControl());\n"; break; case "smallzoom": $output .= "map.addControl(new GSmallZoomControl());\n"; break; case "none": break; case "large": default: $output .= "map.addControl(new GLargeMapControl());\n"; break; } // Scale if ($scalectrl != "none") { $output .= "map.addControl(new GScaleControl());\n"; } // Show Map Type Control and Center if ($typectrl != "none") { $output .= "map.addControl(new GMapTypeControl(true));\n"; } // Double click zoom if ($dbclickzoom) { $output .= "map.enableDoubleClickZoom();\n"; } else { $output .= "map.disableDoubleClickZoom();\n"; } // Continuous zoom if ($continuouszoom) { $output .= "map.enableContinuousZoom();\n"; } else { $output .= "map.disableContinuousZoom();\n"; } // OverviewMap if ($overviewctrl != "none") { $ovw = preg_replace("/(\\d+).*/i", "\$1", $overviewwidth); $ovh = preg_replace("/(\\d+).*/i", "\$1", $overviewheight); if ($ovw == "") { $ovw = PLUGIN_GOOGLEMAPS2_DEF_OVERVIEWWIDTH; } if ($ovh == "") { $ovh = PLUGIN_GOOGLEMAPS2_DEF_OVERVIEWHEIGHT; } $output .= "var ovctrl = new GOverviewMapControl(new GSize({$ovw}, {$ovh}));\n"; $output .= "map.addControl(ovctrl);\n"; if ($overviewctrl == "hide") { $output .= "ovctrl.hide(true);\n"; } } // Geo XML if ($geoxml != "") { $output .= "try {\n"; $output .= "var geoxml = new GGeoXml(\"{$geoxml}\");\n"; $output .= "map.addControl(geoxml);\n"; $output .= "} catch (e) {}\n"; } // GoogleBar if ($googlebar) { $output .= "map.enableGoogleBar();\n"; } // Center Cross Custom Control if ($crossctrl != "none") { $output .= "var crossctrl = new PGCross();\n"; $output .= "crossctrl.initialize(map);\n"; $output .= "var pos = crossctrl.getDefaultPosition();\n"; $output .= "pos.apply(crossctrl.container);\n"; $output .= "var crossChangeStyleFunc = function () {\n"; $output .= "\tswitch (map.getCurrentMapType()) {\n"; $output .= "\t\tcase G_NORMAL_MAP: crossctrl.changeStyle('#000000', 0.5); break;\n"; $output .= "\t\tcase G_SATELLITE_MAP: crossctrl.changeStyle('#FFFFFF', 0.9); break;\n"; $output .= "\t\tcase G_HYBRID_MAP: crossctrl.changeStyle('#FFFFFF', 0.9); break;\n"; $output .= "\t\tdefault: crossctrl.changeStyle('#000000', 0.5); break;\n"; $output .= "\t}\n"; $output .= "}\n"; $output .= "GEvent.addListener(map, 'maptypechanged', crossChangeStyleFunc);\n"; $output .= "crossChangeStyleFunc();\n"; $output .= "googlemaps_crossctrl['{$page}']['{$mapname}'] = crossctrl;\n"; } // マーカーの表示非表示チェックボックス if ($togglemarker) { $output .= "onloadfunc.push( function(){p_googlemaps_togglemarker_checkbox('{$page}', '{$mapname}', '{$noiconname}');} );"; } $output .= "PGTool.transparentGoogleLogo(map);\n"; $output .= "googlemaps_maps['{$page}']['{$mapname}'] = map;\n"; $output .= "googlemaps_markers['{$page}']['{$mapname}'] = new Array();\n"; $output .= "googlemaps_marker_mgrs['{$page}']['{$mapname}'] = marker_mgr;\n"; $output .= "});\n"; $output .= "//]]>\n"; $output .= "</script>\n"; // 指定されたPukiwikiページからアイコンを収集する if ($importicon != "") { $lines = get_source($importicon); foreach ($lines as $line) { $ismatch = preg_match('/googlemaps2_icon\\(.*?\\)/i', $line, $matches); if ($ismatch) { $output .= convert_html("#" . $matches[0]) . "\n"; } } } // このページのバックリンクからマーカーを収集する。 if ($backlinkmarker) { $links = links_get_related_db($vars['page']); if (!empty($links)) { $output .= "<ul>\n"; foreach (array_keys($links) as $page) { $ismatch = preg_match('/#googlemaps2_mark\\(([^, \\)]+), *([^, \\)]+)(.*?)\\)/i', get_source($page, TRUE, TRUE), $matches); if ($ismatch) { $markersource = "&googlemaps2_mark(" . $matches[1] . "," . $matches[2] . ", title=" . $page . ", maxcontent=" . $page; if ($matches[3] != "") { preg_match('/caption=[^,]+/', $matches[3], $m_caption); if ($m_caption) { $markersource .= "," . $m_caption[0]; } preg_match('/icon=[^,]+/', $matches[3], $m_icon); if ($m_icon) { $markersource .= "," . $m_icon[0]; } } $markersource .= ");"; $output .= "<li>" . make_link($markersource) . "</li>\n"; } } $output .= "</ul>\n"; } } return $output; }