function plugin_googlemaps2_draw_output($command, $params) { global $vars; $qm = get_qm(); if (!defined('PLUGIN_GOOGLEMAPS2_DEF_KEY')) { return $qm->replace('plg_googlemaps2.err_not_called', '&googlemaps2_draw()'); } if (!plugin_googlemaps2_is_supported_profile()) { return ''; } if (!array_key_exists('googlemaps2_draw_history', $vars)) { $vars['googlemaps2_draw_history'] = plugin_googlemaps2_draw_get_default(); } $inoptions = array(); $narray = array(); foreach ($params as $param) { $pos = strpos($param, '='); if ($pos == false) { if (is_numeric($param)) { array_push($narray, trim($param)); } continue; } $index = trim(substr($param, 0, $pos)); $value = htmlspecialchars(trim(substr($param, $pos + 1))); $inoptions[$index] = $value; } if (array_key_exists('define', $inoptions)) { $vars['googlemaps2_draw'][$inoptions['define']] = $inoptions; return ""; } $coptions = array(); if (array_key_exists('class', $inoptions)) { $class = $inoptions['class']; if (array_key_exists($class, $vars['googlemaps2_draw'])) { $coptions = $vars['googlemaps2_draw'][$class]; } } $options = array_merge($vars['googlemaps2_draw_history'], $coptions, $inoptions); $vars['googlemaps2_draw_history'] = $options; $opacity = (double) $options['opacity']; $weight = (double) $options['weight']; $color = $options['color']; $map = plugin_googlemaps2_addprefix($vars['page'], $options['map']); $lat = (double) $options['lat']; $lng = (double) $options['lng']; $lat1 = (double) $options['lat1']; $lng1 = (double) $options['lng1']; $lat2 = (double) $options['lat2']; $lng2 = (double) $options['lng2']; $radius = (double) $options['radius']; $inradius = (double) $options['inradius']; $stangle = (double) $options['stangle']; $edangle = (double) $options['edangle']; $rotate = (double) $options['rotate']; $n = (int) $options['n']; $fillopacity = (double) $options['fillopacity']; $fillcolor = $options['fillcolor']; $page = $vars['page']; // Create Marker $err_mapname = $qm->replace('plg_googlemaps2_draw.err_not_def_mapname', $map); $output = <<<EOD <script type="text/javascript"> //<![CDATA[ onloadfunc.push(function() { \tif (document.getElementById("{$map}") == null) { \t\talert("{$err_mapname}"); \t\treturn; \t} \tPGDraw.weight = {$weight}; \tPGDraw.opacity = {$opacity}; \tPGDraw.color = "{$color}"; \tPGDraw.fillopacity = {$fillopacity}; \tPGDraw.fillcolor = "{$fillcolor}"; EOD; switch ($command) { case "line": case "polygon": if (count($narray) < 2) { break; } $output .= "\tvar points = new Array();\n"; for ($i = 0; $i < count($narray); $i++) { $lat = $narray[$i]; $lng = $narray[++$i]; $output .= "\tpoints.push(new GLatLng({$lat}, {$lng}));\n"; } if ($command == "line") { $output .= "\tvar poly = PGDraw.line(points);\n"; } else { $output .= "\tvar poly = PGDraw.polygon(points);\n"; } break; case "rectangle": $output .= "\tvar p1 = new GLatLng(" . $lat1 . ", " . $lng1 . ");\n"; $output .= "\tvar p2 = new GLatLng(" . $lat2 . ", " . $lng2 . ");\n"; $output .= "\tvar poly = PGDraw.rectangle(p1, p2);\n"; break; case "circle": $output .= "\tvar center = new GLatLng(" . $lat . ", " . $lng . ");\n"; $output .= "\tvar outradius = " . $radius . ";\n"; $output .= "\tvar inradius = " . $inradius . ";\n"; $output .= "\tvar poly = PGDraw.circle(center, outradius, inradius);\n"; break; case "arc": $output .= "\tvar center = new GLatLng(" . $lat . ", " . $lng . ");\n"; $output .= "\tvar outradius = " . $radius . ";\n"; $output .= "\tvar inradius = " . $inradius . ";\n"; $output .= "\tvar st = " . $stangle . ";\n"; $output .= "\tvar ed = " . $edangle . ";\n"; $output .= "\tvar poly = PGDraw.arc(center, outradius, inradius, st, ed);\n"; break; case "ngon": $output .= "\tvar center = new GLatLng(" . $lat . ", " . $lng . ");\n"; $output .= "\tvar radius = " . $radius . ";\n"; $output .= "\tvar rotate = " . $rotate . ";\n"; $output .= "\tvar n = " . $n . ";\n"; $output .= "\tvar poly = PGDraw.ngon(center, radius, n, rotate);\n"; break; default: $output .= "\tvar poly = null;\n"; } $output .= "\tif (poly) googlemaps_maps['{$page}']['{$map}'].addOverlay(poly);\n"; $output .= <<<EOD }); //]]> </script> EOD; return $output; }
function plugin_googlemaps2_insertmarker_convert() { global $vars, $digest, $script; static $numbers = array(); $qm = get_qm(); if (!defined('PLUGIN_GOOGLEMAPS2_DEF_KEY')) { return $qm->replace('plg_googlemaps2.err_not_called', 'googlemaps2_insertmarker'); } if (!plugin_googlemaps2_is_supported_profile()) { return ''; } if (PKWK_READONLY) { return $qm->m['fmt_err_pkwk_readonly'] . "<br>"; } //オプション $defoptions = plugin_googlemaps2_insertmarker_get_default(); $inoptions = array(); foreach (func_get_args() 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 (array_key_exists('define', $inoptions)) { $vars['googlemaps2_insertmarker'][$inoptions['define']] = $inoptions; return ''; } $coptions = array(); if (array_key_exists('class', $inoptions)) { $class = $inoptions['class']; if (array_key_exists($class, $vars['googlemaps2_insertmarker'])) { $coptions = $vars['googlemaps2_icon'][$class]; } } $options = array_merge($defoptions, $coptions, $inoptions); $map = plugin_googlemaps2_addprefix($vars['page'], $options['map']); $mapname = $options['map']; //ユーザーに表示させるだけのマップ名(prefix除いた名前) $direction = $options['direction']; $script = get_script_uri(); $s_page = $vars['page']; if (!isset($numbers[$s_page])) { $numbers[$s_page] = 0; } $no = $numbers[$s_page]++; $imprefix = "_p_googlemaps2_insertmarker_" . $s_page . "_" . $no; $err_map_not_found = $qm->replace('plg_googlemaps2_insertmarker.err_map_not_found', $mapname); $output = <<<EOD <form action="{$script}" id="{$imprefix}_form" method="post"> <div style="padding:2px;"> <input type="hidden" name="plugin" value="googlemaps2_insertmarker" /> <input type="hidden" name="refer" value="{$s_page}" /> <input type="hidden" name="direction" value="{$direction}" /> <input type="hidden" name="no" value="{$no}" /> <input type="hidden" name="digest" value="{$digest}" /> <input type="hidden" name="map" value="{$mapname}" /> <input type="hidden" name="zoom" value="10" id="{$imprefix}_zoom"/> <input type="hidden" name="mtype" value="0" id="{$imprefix}_mtype"/> {$qm->m['plg_googlemaps2_insertmarker']['label_latitude']}: <input type="text" name="lat" id="{$imprefix}_lat" size="10" /> {$qm->m['plg_googlemaps2_insertmarker']['label_longitude']}: <input type="text" name="lng" id="{$imprefix}_lng" size="10" /> {$qm->m['plg_googlemaps2_insertmarker']['label_title']}: <input type="text" name="title" id="{$imprefix}_title" size="20" /> {$qm->m['plg_googlemaps2_insertmarker']['label_icon']}: <select name="icon" id ="{$imprefix}_icon"> <option value="Default">{$qm->m['plg_googlemaps2_insertmarker']['option_default']}</option> </select> <br /> {$qm->m['plg_googlemaps2_insertmarker']['label_img']}: <input type="text" name="image" id="{$imprefix}_image" size="20" /> {$qm->m['plg_googlemaps2_insertmarker']['label_maxurl']}: <input type="text" name="maxurl" id="{$imprefix}_maxurl" size="20" /> <br /> {$qm->m['plg_googlemaps2_insertmarker']['label_minzoom']}: <select name="minzoom" id ="{$imprefix}_minzoom"> <option value="">--</option> <option value="0"> 0</option> <option value="1"> 1</option> <option value="2"> 2</option> <option value="3"> 3</option> <option value="4"> 4</option> <option value="5"> 5</option> <option value="6"> 6</option> <option value="7"> 7</option> <option value="8"> 8</option> <option value="9"> 9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> </select> {$qm->m['plg_googlemaps2_insertmarker']['label_maxzoom']}: <select name="maxzoom" id ="{$imprefix}_maxzoom"> <option value="">--</option> <option value="0"> 0</option> <option value="1"> 1</option> <option value="2"> 2</option> <option value="3"> 3</option> <option value="4"> 4</option> <option value="5"> 5</option> <option value="6"> 6</option> <option value="7"> 7</option> <option value="8"> 8</option> <option value="9"> 9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> </select> <br /> {$qm->m['plg_googlemaps2_insertmarker']['label_detail']}: <textarea name="caption" id="{$imprefix}_caption" rows="2" cols="55"></textarea> <input type="submit" name="Mark" value="{$qm->m['plg_googlemaps2_insertmarker']['btn_mark']}"/> </div> </form> <script type="text/javascript"> //<![CDATA[ onloadfunc.push(function() { \tvar map = googlemaps_maps['{$s_page}']['{$map}']; \tif (!map) { \t\tvar form = document.getElementById("{$imprefix}_form"); \t\tform.innerHTML = '<div>{$err_map_not_found}</div>'; \t} else { \t\tvar lat = document.getElementById("{$imprefix}_lat"); \t\tvar lng = document.getElementById("{$imprefix}_lng"); \t\tvar zoom = document.getElementById("{$imprefix}_zoom"); \t\tvar mtype = document.getElementById("{$imprefix}_mtype"); \t\tvar form = document.getElementById("{$imprefix}_form"); \t\tvar icon = document.getElementById("{$imprefix}_icon"); \t\t//地図がドラッグされたりするたびに動的にパラメータを代入する \t\tGEvent.addListener(map, 'moveend', function() { \t\t\tlat.value = PGTool.fmtNum(map.getCenter().lat()); \t\t\tlng.value = PGTool.fmtNum(map.getCenter().lng()); \t\t\tzoom.value = parseInt(map.getZoom()); \t\t\tmtype.value = -1; \t\t\tvar curmaptype = map.getCurrentMapType(); \t\t\tvar maptypes = map.getMapTypes(); \t\t\tvar cname = curmaptype.getName(false); \t\t\tfor (i in maptypes) { \t\t\t\tif (maptypes[i].getName(false) == cname) { \t\t\t\t\tmtype.value = i; \t\t\t\t\tbreak; \t\t\t\t} \t\t\t} \t\t}); \t\t \t\t//クッキーがあれば地図の位置を初期化をする。使い終えたらクッキーの中身をクリアする。 \t\t(function () { \t\t\tvar cookies = document.cookie.split(";"); \t\t\tfor (i in cookies) { \t\t\t\tvar kv = cookies[i].split("="); \t\t\t\tfor (j in kv) { \t\t\t\t\tkv[j] = kv[j].replace(/^\\s+|\\s+\$/g, ""); \t\t\t\t} \t\t\t\tif (kv[0] == "pukiwkigooglemaps2insertmarker{$no}") { \t\t\t\t\tif (kv.length == 2 && kv[1].length > 0) { \t\t\t\t\t\tvar mparam = {lat:0, lng:0, zoom:10, mtype:0}; \t\t\t\t\t\tvar oparam = {maxzoom:"", minzoom:""}; \t\t\t\t\t\tvar params = decodeURIComponent(kv[1]).split("|"); \t\t\t\t\t\tfor (var j = 0; j < params.length; j++) { \t\t\t\t\t\t\t//dump(params[j] + "=" + params[j+1] + "\\n"); \t\t\t\t\t\t\tswitch (params[j]) { \t\t\t\t\t\t\t\tcase "lat": mparam.lat = parseFloat(params[++j]); break; \t\t\t\t\t\t\t\tcase "lng": mparam.lng = parseFloat(params[++j]); break; \t\t\t\t\t\t\t\tcase "zoom": mparam.zoom = parseInt(params[++j]); break; \t\t\t\t\t\t\t\tcase "mtype": mparam.mtype = parseInt(params[++j]); break; \t\t\t\t\t\t\t\tcase "maxzoom": oparam.maxzoom = parseInt(params[++j]); break; \t\t\t\t\t\t\t\tcase "minzoom": oparam.minzoom = parseInt(params[++j]); break; \t\t\t\t\t\t\t\tdefault: j++; break; \t\t\t\t\t\t\t} \t\t\t\t\t\t} \t\t\t\t\t\tmap.setCenter(new GLatLng(mparam.lat, mparam.lng), \t\t\t\t\t\t\t\tmparam.zoom, map.getMapTypes()[mparam.mtype]); \t\t\t\t\t\tvar smz; \t\t\t\t\t\tvar options; \t\t\t\t\t\tsmz = document.getElementById("{$imprefix}_minzoom") \t\t\t\t\t\toptions = smz.childNodes; \t\t\t\t\t\tfor (var j=0; j<options.length; j++) { \t\t\t\t\t\t\tvar option = options.item(j); \t\t\t\t\t\t\tif (option.value == oparam.minzoom) { \t\t\t\t\t\t\t\toption.selected = true; \t\t\t\t\t\t\t\tbreak; \t\t\t\t\t\t\t} \t\t\t\t\t\t} \t\t\t\t\t\tsmz = document.getElementById("{$imprefix}_maxzoom") \t\t\t\t\t\toptions = smz.childNodes; \t\t\t\t\t\tfor (var j=0; j<options.length; j++) { \t\t\t\t\t\t\tvar option = options.item(j); \t\t\t\t\t\t\tif (option.value == oparam.maxzoom) { \t\t\t\t\t\t\t\toption.selected = true; \t\t\t\t\t\t\t\tbreak; \t\t\t\t\t\t\t} \t\t\t\t\t\t} \t\t\t\t\t} \t\t\t\t\tbreak; \t\t\t\t} \t\t\t} \t\t\tdocument.cookie = "pukiwkigooglemaps2insertmarker{$no}=;"; \t\t})(); \t\t//入力チェック \t\tform.onsubmit = function () { \t\t\tif (isNaN(parseFloat(lat.value)) || isNaN(lat.value) || \t\t\t\tisNaN(parseFloat(lng.value)) || isNaN(lng.value)) { \t\t\t\talert({$qm->m['plg_googlemaps2_insertmarker']['err_invalid_coor']}); \t\t\t\treturn false; \t\t\t} \t\t\treturn true; \t\t}; \t} \t//このページに存在しているicon定義を全て読みこんでセレクトを更新。 \tonloadfunc.push(function() { \t\tfor(iconname in googlemaps_icons['{$s_page}']) { \t\t\tvar opt = document.createElement("option"); \t\t\topt.value = iconname; \t\t\topt.appendChild(document.createTextNode(iconname)); \t\t\ticon.appendChild(opt); \t\t} \t}); }); //]]> </script> EOD; return $output; }
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; }