diff --git a/htdocs/map2.php b/htdocs/map2.php index 0b0a125a..517ae00d 100644 --- a/htdocs/map2.php +++ b/htdocs/map2.php @@ -64,11 +64,9 @@ else $tpl->error($translate->t('There is no google maps key registered for this domain.', '', '', 0)); - $tpl->add_header_javascript('http://maps.google.com/maps?file=api&v=2.x&key=' . urlencode($sGMKey)); - $tpl->add_header_javascript('resource2/misc/map/dragzoom_packed.js'); - $tpl->add_header_javascript('resource2/misc/map/LatLonDisplayControl.js'); + //$tpl->add_header_javascript('https://maps.googleapis.com/maps/api/js?key=' . urlencode($sGMKey) . '&sensor=false'); + $tpl->add_header_javascript('https://maps.googleapis.com/maps/api/js?sensor=false'); $tpl->add_header_javascript('resource2/misc/map/CacheMarker.js'); - //$tpl->add_header_javascript('resource2/misc/map/MessageControl.js'); $tpl->add_body_load('mapLoad()'); $tpl->add_body_unload('GUnload()'); @@ -268,7 +266,7 @@ function output_namesearch($sName, $nLat, $nLon, $nResultId) `caches`.`name`, `caches`.`wp_oc` FROM `map2_data` INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id` - INNeR JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` + INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `caches`.`name` LIKE '&1' AND (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&3') AND `map2_data`.`result_id`='&2' @@ -287,7 +285,7 @@ function output_namesearch($sName, $nLat, $nLon, $nResultId) function output_searchresult($nResultId, $nLon1, $nLat1, $nLon2, $nLat2) { - global $opt; + global $login, $opt; // check if data is available and connect the right slave server $nSlaveId = sql_value("SELECT `slave_id` FROM `map2_result` WHERE `result_id`='&1' AND DATE_ADD(`date_created`, INTERVAL '&2' SECOND)>NOW()", -2, $nResultId, $opt['map']['maxcacheage']); @@ -313,10 +311,16 @@ function output_searchresult($nResultId, $nLon1, $nLat1, $nLon2, $nLat2) if ($bMaxRecordReached == false) { - $rs = sql_slave("SELECT SQL_BUFFER_RESULT `caches`.`wp_oc`, `caches`.`longitude`, `caches`.`latitude`, `caches`.`type` FROM `map2_data` INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id` WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5' LIMIT " . ($opt['map']['maxrecords']+0), $nResultId, $nLon1, $nLon2, $nLat1, $nLat2); + $foundQuery = "(SELECT COUNT(*) FROM `cache_logs` WHERE `cache_logs`.`cache_id`=`caches`.`cache_id` AND `user_id`='" . $login->userid . "' AND `cache_logs`.`type` IN (1,7))"; + $ownedQuery = "IF(`caches`.`user_id`='" . $login->userid . "', 1, 0 )"; + + $rs = sql_slave("SELECT SQL_BUFFER_RESULT `caches`.`wp_oc`, `caches`.`longitude`, `caches`.`latitude`, `caches`.`type`, " . $ownedQuery . " AS `owned`, " . $foundQuery . " AS `found` FROM `map2_data` INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id` WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5' LIMIT " . ($opt['map']['maxrecords']+0), $nResultId, $nLon1, $nLon2, $nLat1, $nLat2); while ($r = sql_fetch_assoc($rs)) { - echo '' . "\n"; + $oc_wp = xmlentities($r['wp_oc']); + $owned = xmlentities($r['owned']); + $found = (xmlentities($r['found']) > 0 ? 1 : 0); + echo '' . "\n"; } sql_free_result($rs); } @@ -324,4 +328,4 @@ function output_searchresult($nResultId, $nLon1, $nLat1, $nLon2, $nLat2) exit; } -?> \ No newline at end of file +?> diff --git a/htdocs/map2full.php b/htdocs/map2full.php new file mode 100644 index 00000000..ee9d1064 --- /dev/null +++ b/htdocs/map2full.php @@ -0,0 +1,331 @@ +verify(); + + $sMode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : ''; + if ($sMode == 'locate') + { + $nLat = isset($_REQUEST['lat']) ? $_REQUEST['lat']+0 : 0; + $nLon = isset($_REQUEST['lon']) ? $_REQUEST['lon']+0 : 0; + $nDistance = isset($_REQUEST['distance']) ? $_REQUEST['distance']+0 : 5; + if ($nDistance > 150) $nDistance = 150; + + cache_locate($nLat, $nLon, $nDistance); + } + else if ($sMode == 'wpsearch') + { + $sWaypoint = isset($_REQUEST['wp']) ? $_REQUEST['wp'] : ''; + output_cachexml($sWaypoint); + } + else if ($sMode == 'namesearch') + { + $sName = isset($_REQUEST['name']) ? $_REQUEST['name'] : ''; + $nLat = isset($_REQUEST['lat']) ? $_REQUEST['lat']+0 : 0; + $nLon = isset($_REQUEST['lon']) ? $_REQUEST['lon']+0 : 0; + $nResultId = isset($_REQUEST['resultid']) ? $_REQUEST['resultid']+0 : 0; + output_namesearch($sName, $nLat, $nLon, $nResultId); + } + else if ($sMode == 'searchresult') + { + $nResultId = isset($_REQUEST['resultid']) ? $_REQUEST['resultid']+0 : 0; + $nLon1 = isset($_REQUEST['lon1']) ? $_REQUEST['lon1']+0 : 0; + $nLon2 = isset($_REQUEST['lon2']) ? $_REQUEST['lon2']+0 : 0; + $nLat1 = isset($_REQUEST['lat1']) ? $_REQUEST['lat1']+0 : 0; + $nLat2 = isset($_REQUEST['lat2']) ? $_REQUEST['lat2']+0 : 0; + + output_searchresult($nResultId, $nLon1, $nLat1, $nLon2, $nLat2); + } + else if ($sMode == 'fullscreen') + { + $tpl->popup = true; + $tpl->popupmargin = false; + } + + $tpl->name = 'map2full'; + $tpl->menuitem = MNU_MAP; + $tpl->nowpsearch = true; + + // get the correct mapkey + $sHost = strtolower($_SERVER['HTTP_HOST']); + if (isset($opt['lib']['google']['mapkey'][$sHost])) + $sGMKey = $opt['lib']['google']['mapkey'][$sHost]; + else + $tpl->error($translate->t('There is no google maps key registered for this domain.', '', '', 0)); + + //$tpl->add_header_javascript('https://maps.googleapis.com/maps/api/js?key=' . urlencode($sGMKey) . '&sensor=false'); + $tpl->add_header_javascript('https://maps.googleapis.com/maps/api/js?sensor=false'); + $tpl->add_header_javascript('resource2/misc/map/CacheMarker.js'); + $tpl->add_body_load('mapLoad()'); + $tpl->add_body_unload('GUnload()'); + + // process start params + $bGMInitCookiePos = true; + if (isset($_REQUEST['lat']) && + isset($_REQUEST['lon']) && + isset($_REQUEST['zoom'])) + { + $nGMInitLat = $_REQUEST['lat']+0; + $nGMInitLon = $_REQUEST['lon']+0; + $nGMInitZoom = $_REQUEST['zoom']+0; + $bGMInitCookiePos = false; + } + else + { + // init GM from user country selection + $rsCoords = sql("SELECT `gmLat`, `gmLon`, `gmZoom` FROM `countries_options` WHERE `country`='&1'", $login->getUserCountry()); + $rCoord = sql_fetch_assoc($rsCoords); + sql_free_result($rsCoords); + + if ($rCoord !== false) + { + $nGMInitLat = $rCoord['gmLat']; + $nGMInitLon = $rCoord['gmLon']; + $nGMInitZoom = $rCoord['gmZoom']; + } + else + { + // europe is the last fallback + $nGMInitLat = 52.74959372674114; + $nGMInitLon = 10.01953125; + $nGMInitZoom = 4; + } + } + + $sGMInitWaypoint = isset($_REQUEST['wp']) ? $_REQUEST['wp'] : ''; + if ($sGMInitWaypoint != '') + { + $cache = cache::fromWP($sGMInitWaypoint); + if ($cache == null) + $sGMInitWaypoint = ''; + else + { + if ($cache->allowView()) + { + $nGMInitLon = $cache->getLongitude(); + $nGMInitLat = $cache->getLatitude(); + $nGMInitZoom = 13; + $bGMInitCookiePos = false; + } + else + $sGMInitWaypoint = ''; + } + } + + $tpl->assign('nGMInitLon', $nGMInitLon); + $tpl->assign('nGMInitLat', $nGMInitLat); + $tpl->assign('nGMInitZoom', $nGMInitZoom); + $tpl->assign('bGMInitCookiePos', ($bGMInitCookiePos ? 1 : 0)); + $tpl->assign('sGMInitWaypoint', $sGMInitWaypoint); + $tpl->assign('bFullscreen', ($sMode == 'fullscreen' ? 1 : 0)); + $tpl->assign('bDisableFullscreen', $opt['map']['disablefullscreen']); + + $rsCacheType = sql("SELECT `cache_type`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_type`.`name`) AS `text` FROM `cache_type` LEFT JOIN `sys_trans` ON `cache_type`.`trans_id`=`sys_trans`.`id` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `cache_type`.`ordinal` ASC", $opt['template']['locale']); + $tpl->assign_rs('aCacheType', $rsCacheType); + sql_free_result($rsCacheType); + + $rsCacheSize = sql("SELECT `cache_size`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_size`.`name`) AS `text` FROM `cache_size` LEFT JOIN `sys_trans` ON `cache_size`.`trans_id`=`sys_trans`.`id` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' ORDER BY `cache_size`.`ordinal` ASC", $opt['template']['locale']); + $tpl->assign_rs('aCacheSize', $rsCacheSize); + sql_free_result($rsCacheSize); + + /* assign attributes */ + $tpl->assign('aAttributes', attribute::getAttrbutesListArray()); + + $aAttributesDisabled = array(); + $rs = sql("SELECT `id` FROM `cache_attrib`"); + while ($r = sql_fetch_assoc($rs)) + $aAttributesDisabled[] = $r['id']; + sql_free_result($rs); + $tpl->assign('aAttributesDisabled', $aAttributesDisabled); + + $tpl->display(); + +function cache_locate($nLat, $nLon, $nDistance) +{ + global $login; + + $rsCache = sql_slave("SELECT " . geomath::getSqlDistanceFormula($nLon, $nLat, $nDistance) . " AS `distance`, + `caches`.`wp_oc` + FROM `caches` + INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` + WHERE `caches`.`latitude`>'&1' AND + `caches`.`latitude`<'&2' AND + `caches`.`longitude`>'&3' AND + `caches`.`longitude`<'&4' AND + (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&1') + ORDER BY `distance` ASC LIMIT 1", + geomath::getMinLat($nLon, $nLat, $nDistance), + geomath::getMaxLat($nLon, $nLat, $nDistance), + geomath::getMinLon($nLon, $nLat, $nDistance), + geomath::getMaxLon($nLon, $nLat, $nDistance), + $login->userid); + $rCache = sql_fetch_assoc($rsCache); + sql_free_result($rsCache); + + if ($rCache === false) + { + echo ''; + exit; + } + + output_cachexml($rCache['wp_oc']); +} + +function output_cachexml($sWaypoint) +{ + global $opt, $login; + + $rsCache = sql_slave("SELECT `caches`.`name`, `caches`.`wp_oc`, `caches`.`cache_id`, `caches`.`type`, + `caches`.`longitude`, `caches`.`latitude`, + IF(`caches`.`status`=2, 1, 0) AS `tna`, + IFNULL(`trans_status_text`.`text`, `cache_status`.`name`) AS `statustext`, + IFNULL(`trans_type_text`.`text`, `cache_type`.`name`) AS `type_text`, `cache_type`.`id` AS `type_id`, + IFNULL(`trans_size_text`.`text`, `cache_size`.`name`) AS `size`, + `caches`.`difficulty`, `caches`.`terrain`, + `caches`.`date_created`, + IFNULL(`stat_caches`.`toprating`, 0) AS `toprating`, + IF(`caches`.`user_id`='&1', 1, 0) AS `owner`, + `user`.`username`, `user`.`user_id` + FROM `caches` + INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id` + INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` + INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id` + INNER JOIN `cache_size` ON `caches`.`size`=`cache_size`.`id` + LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id` + LEFT JOIN `sys_trans` AS `trans_status` ON `cache_status`.`trans_id`=`trans_status`.`id` AND `cache_status`.`name`=`trans_status`.`text` + LEFT JOIN `sys_trans_text` AS `trans_status_text` ON `trans_status`.`id`=`trans_status_text`.`trans_id` AND `trans_status_text`.`lang`='&2' + LEFT JOIN `sys_trans` AS `trans_type` ON `cache_type`.`trans_id`=`trans_type`.`id` AND `cache_type`.`name`=`trans_type`.`text` + LEFT JOIN `sys_trans_text` AS `trans_type_text` ON `trans_type`.`id`=`trans_type_text`.`trans_id` AND `trans_type_text`.`lang`='&2' + LEFT JOIN `sys_trans` AS `trans_size` ON `cache_size`.`trans_id`=`trans_size`.`id` AND `cache_size`.`name`=`trans_size`.`text` + LEFT JOIN `sys_trans_text` AS `trans_size_text` ON `trans_size`.`id`=`trans_size_text`.`trans_id` AND `trans_size_text`.`lang`='&2' + WHERE (`caches`.`wp_oc`='&3' OR (`caches`.`wp_oc`!='&3' AND `caches`.`wp_gc`='&3') OR (`caches`.`wp_oc`!='&3' AND `caches`.`wp_nc`='&3')) AND + (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&1')", + $login->userid, $opt['template']['locale'], $sWaypoint); + $rCache = sql_fetch_assoc($rsCache); + sql_free_result($rsCache); + + if ($rCache === false) + { + echo ''; + exit; + } + + $nGeokretyCount = sql_value_slave("SELECT COUNT(*) FROM `gk_item_waypoint` WHERE `wp`='&1'", 0, $sWaypoint); + $nNotFoundCount = $nAttendedCount = 0; + $nFoundCount = sql_value_slave("SELECT COUNT(*) FROM `cache_logs` WHERE `user_id`='&1' AND `cache_id`='&2' AND `type`=1", 0, $login->userid, $rCache['cache_id']); + if ($nFoundCount == 0) + $nNotFoundCount = sql_value_slave("SELECT COUNT(*) FROM `cache_logs` WHERE `user_id`='&1' AND `cache_id`='&2' AND `type`=2", 0, $login->userid, $rCache['cache_id']); + if ($rCache['type'] == 6) + $nAttendedCount = sql_value_slave("SELECT COUNT(*) FROM `cache_logs` WHERE `user_id`='&1' AND `cache_id`='&2' AND `type`=7", 0, $login->userid, $rCache['cache_id']); + + echo '' . "\n"; + echo ' ' . "\n"; + echo ''; + + exit; +} + +function output_namesearch($sName, $nLat, $nLon, $nResultId) +{ + global $login; + + $sName = '%' . $sName . '%'; + + echo '' . "\n"; + $rs = sql_slave("SELECT " . geomath::getSqlDistanceFormula($nLon, $nLat, 0) . " AS `distance`, + `caches`.`name`, `caches`.`wp_oc` + FROM `map2_data` + INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id` + INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` + WHERE `caches`.`name` LIKE '&1' + AND (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&3') + AND `map2_data`.`result_id`='&2' + ORDER BY `distance` ASC LIMIT 30", + $sName, + $nResultId, + $login->userid); + while ($r = sql_fetch_assoc($rs)) + { + echo '' . "\n"; + } + sql_free_result($rs); + echo ''; + exit; +} + +function output_searchresult($nResultId, $nLon1, $nLat1, $nLon2, $nLat2) +{ + global $login, $opt; + + // check if data is available and connect the right slave server + $nSlaveId = sql_value("SELECT `slave_id` FROM `map2_result` WHERE `result_id`='&1' AND DATE_ADD(`date_created`, INTERVAL '&2' SECOND)>NOW()", -2, $nResultId, $opt['map']['maxcacheage']); + if ($nSlaveId == -2) + { + echo ''; + echo ''; + exit; + } + sql_connect_slave($nSlaveId); + + sql("UPDATE `map2_result` SET `request_counter`=`request_counter`+1, `date_lastqueried`=NOW() WHERE `result_id`='&1'", $nResultId); + + // execute query and return search result + $nRecordCount = sql_value_slave("SELECT COUNT(*) FROM `map2_data` INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id` WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5'", 0, $nResultId, $nLon1, $nLon2, $nLat1, $nLat2); + // TODO: SQL_CALC_FOUND_ROWS + $nRecordCount = sql_value_slave("SELECT FOUND_ROWS()", 0); + + $bMaxRecordReached = false; + if ($nRecordCount > $opt['map']['maxrecords']) + $bMaxRecordReached = true; + + echo '' . "\n"; + + if ($bMaxRecordReached == false) + { + $foundQuery = "(SELECT COUNT(*) FROM `cache_logs` WHERE `cache_logs`.`cache_id`=`caches`.`cache_id` AND `user_id`='" . $login->userid . "' AND `cache_logs`.`type` IN (1,7))"; + $ownedQuery = "IF(`caches`.`user_id`='" . $login->userid . "', 1, 0 )"; + + $rs = sql_slave("SELECT SQL_BUFFER_RESULT `caches`.`wp_oc`, `caches`.`longitude`, `caches`.`latitude`, `caches`.`type`, " . $ownedQuery . " AS `owned`, " . $foundQuery . " AS `found` FROM `map2_data` INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id` WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5' LIMIT " . ($opt['map']['maxrecords']+0), $nResultId, $nLon1, $nLon2, $nLat1, $nLat2); + while ($r = sql_fetch_assoc($rs)) + { + $oc_wp = xmlentities($r['wp_oc']); + $owned = xmlentities($r['owned']); + $found = (xmlentities($r['found']) > 0 ? 1 : 0); + echo '' . "\n"; + } + sql_free_result($rs); + } + echo ''; + + exit; +} +?> diff --git a/htdocs/resource2/misc/map/CacheMarker.js b/htdocs/resource2/misc/map/CacheMarker.js index 2e8678bf..0917e14d 100644 --- a/htdocs/resource2/misc/map/CacheMarker.js +++ b/htdocs/resource2/misc/map/CacheMarker.js @@ -1,18 +1,30 @@ -function CacheMarker(latlng, wp, type) +function CacheMarker(latlng, wp, type, owned, found, map) { this.latlng = latlng; this.wp_ = wp; - this.image_ = 'resource2/ocstyle/images/map/24x24-cachetype-' + type + '.png'; + if(found) { + this.image_ = 'resource2/ocstyle/images/map/24x24-found.png'; + } + /* + else if(owned) { + this.image_ = 'resource2/ocstyle/images/map/24x24-owned.png'; + } + */ + else { + this.image_ = 'resource2/ocstyle/images/map/24x24-cachetype-' + type + '.png'; + } this.height_ = 24; this.width_ = 24; + this.map_ = map; + this.setMap( map ); } -CacheMarker.prototype = new GOverlay(); +CacheMarker.prototype = new google.maps.OverlayView; /* Creates the DIV representing this CacheMarker. * @param map {GMap2} Map that bar overlay is added to. */ -CacheMarker.prototype.initialize = function(map) { +CacheMarker.prototype.onAdd = function() { var me = this; // Create the DIV representing our CacheMarker @@ -28,43 +40,41 @@ CacheMarker.prototype.initialize = function(map) { img.style.width = me.width_ + "px"; img.style.height = me.height_ + "px"; div.appendChild(img); - GEvent.addDomListener(div, "click", function() + google.maps.event.addDomListener(div, "click", function() { - GEvent.trigger(me, "click", me.wp_); + google.maps.event.trigger(me, "click", me.wp_); }); - map.getPane(G_MAP_MARKER_PANE).appendChild(div); - - this.map_ = map; + //map.getPane(G_MAP_MARKER_PANE).appendChild(div); + var pane = this.getPanes().overlayImage; + pane.appendChild(div); + this.div_ = div; }; /* Remove the main DIV from the map pane */ -CacheMarker.prototype.remove = function() { +CacheMarker.prototype.onRemove = function() { this.div_.parentNode.removeChild(this.div_); + this.div_ = null; }; /* Redraw the CacheMarker based on the current projection and zoom level * @param force {boolean} Helps decide whether to redraw overlay */ -CacheMarker.prototype.redraw = function(force) { - - // We only need to redraw if the coordinate system has changed - if (!force) return; - +CacheMarker.prototype.draw = function() { // Calculate the DIV coordinates of two opposite corners // of our bounds to get the size and position of our CacheMarker - var divPixel = this.map_.fromLatLngToDivPixel(this.latlng); + var divPixel = this.getProjection().fromLatLngToDivPixel(this.latlng); // Now position our DIV based on the DIV coordinates of our bounds this.div_.style.width = this.width_ + "px"; - this.div_.style.left = (divPixel.x) + "px" + this.div_.style.left = (divPixel.x-this.width_/2) + "px" this.div_.style.height = (this.height_) + "px"; - this.div_.style.top = (divPixel.y) - this.height_ + "px"; + this.div_.style.top = (divPixel.y+this.height_/2) - this.height_ + "px"; }; CacheMarker.prototype.getZIndex = function(m) { - return GOverlay.getZIndex(marker.getPoint().lat())-m.clicked*10000; + return google.maps.Overlay.getZIndex(marker.getPoint().lat())-m.clicked*10000; } CacheMarker.prototype.getPoint = function() { diff --git a/htdocs/resource2/ocstyle/images/map/32x32-left.png b/htdocs/resource2/ocstyle/images/map/32x32-left.png new file mode 100644 index 00000000..f1762ab0 Binary files /dev/null and b/htdocs/resource2/ocstyle/images/map/32x32-left.png differ diff --git a/htdocs/resource2/ocstyle/images/map/32x32-right.png b/htdocs/resource2/ocstyle/images/map/32x32-right.png new file mode 100644 index 00000000..ebfeedc0 Binary files /dev/null and b/htdocs/resource2/ocstyle/images/map/32x32-right.png differ diff --git a/htdocs/resource2/ocstyle/images/map/35x35-normalscreen.png b/htdocs/resource2/ocstyle/images/map/35x35-normalscreen.png new file mode 100644 index 00000000..ad1f53c9 Binary files /dev/null and b/htdocs/resource2/ocstyle/images/map/35x35-normalscreen.png differ diff --git a/htdocs/templates2/ocstyle/map2.tpl b/htdocs/templates2/ocstyle/map2.tpl index d15a78c7..4261500d 100644 --- a/htdocs/templates2/ocstyle/map2.tpl +++ b/htdocs/templates2/ocstyle/map2.tpl @@ -38,18 +38,20 @@
- - -
- + + - + + + {t}Show link to this map{/t} {if !$bDisableFullscreen} {t}Switch to full screen{/t} {/if} + {t}Switch to full screen{/t} {t}Download GPX file (max. 500){/t} + {t}Goto home coordinates{/t}
@@ -277,1052 +279,1275 @@ {/if} {literal} - + } + sPostBody += '&cachetype=' + sCacheTypes; + + /* cachesize + */ + var nCacheSizeCount = {/literal}{count array=$aCacheSize}{literal}; + var sCacheSizes = ''; + for (var i=1; i<=nCacheSizeCount; i++) + { + if (document.getElementById('cachesize' + i).checked) + { + if (sCacheSizes != '') sCacheSizes += ';'; + sCacheSizes += i; + } + } + sPostBody += '&cachesize=' + sCacheSizes; + + /* hide options + */ + sPostBody += document.getElementById('f_userowner').checked ? '&f_userowner=1' : ''; + sPostBody += document.getElementById('f_userfound').checked ? '&f_userfound=1' : ''; + sPostBody += document.getElementById('f_ignored').checked ? '&f_ignored=1' : ''; + sPostBody += document.getElementById('f_inactive').checked ? '&f_inactive=1' : '&f_inactive=0'; + sPostBody += document.getElementById('f_otherPlatforms').checked ? '&f_otherPlatforms=1' : ''; + + /* rating options + */ + nSelectValue = document.getElementById('terrainmin').value; + if (nSelectValue != 0) sPostBody += '&terrainmin=' + nSelectValue; + nSelectValue = document.getElementById('terrainmax').value; + if (nSelectValue != 0) sPostBody += '&terrainmax=' + nSelectValue; + nSelectValue = document.getElementById('difficultymin').value; + if (nSelectValue != 0) sPostBody += '&difficultymin=' + nSelectValue; + nSelectValue = document.getElementById('difficultymax').value; + if (nSelectValue != 0) sPostBody += '&difficultymax=' + nSelectValue; + nSelectValue = document.getElementById('recommendationmin').value; + if (nSelectValue != 0) sPostBody += '&recommendationmin=' + nSelectValue; + + /* attributes + */ + var sCacheAttribs = ''; + var sCacheAttribsNot = ''; + for (var nCacheAttribIndex=1; nCacheAttribIndex<100; nCacheAttribIndex++) + { + if (document.getElementById('attribute' + nCacheAttribIndex)) + { + var nValue = document.getElementById('attribute' + nCacheAttribIndex).value; + if (nValue == '1') + { + if (sCacheAttribs != '') sCacheAttribs += ';'; + sCacheAttribs += nCacheAttribIndex; + } + else if (nValue == '2') + { + if (sCacheAttribsNot != '') sCacheAttribsNot += ';'; + sCacheAttribsNot += nCacheAttribIndex; + } + } + } + sPostBody += '&cache_attribs=' + sCacheAttribs; + sPostBody += '&cache_attribs_not=' + sCacheAttribsNot; + + return sPostBody; +} + +// built query string for map2.php +function get_mapfilter_params() +{ + var oBounds = moMap.getBounds(); + var sPostBody = 'mode=searchresult&resultid=' + mnResultId; + sPostBody += '&lat1=' + oBounds.getSouthWest().lat(); + sPostBody += '&lat2=' + oBounds.getNorthEast().lat(); + sPostBody += '&lon1=' + oBounds.getSouthWest().lng(); + sPostBody += '&lon2=' + oBounds.getNorthEast().lng(); + return sPostBody; +} + +function data_clear() +{ + document.getElementById('statCachesCount').firstChild.nodeValue = 0; + + if (msPopupMarkerWP == '') + { + // remove every waypoint and popups etc. + + for (var nIndex=0; nIndex0)); + + /* nee too many markers -> clear all and display message */ + if (oXML.documentElement.getAttribute("maxrecordreached") == 1) + { + data_clear(); + tmd_show(record_count); + return; + } + + /* compute set of markers to keep */ + var wpset = {}; + var oCachesList = oXML.documentElement.getElementsByTagName("cache"); + for (var nIndex=0; nIndex 0 ); + var bFound = ( oCachesList[nIndex].getAttribute("found") > 0 ); + + addCacheToMap(sWaypoint, nLon, nLat, nType, bOwned, bFound); + } + } + + document.getElementById('statCachesCount').firstChild.nodeValue = oCachesList.length; + document.getElementById('statLoadTime').firstChild.nodeValue = getTimeDiff(mbDataDownloadStartTime, new Date()); +} + +function download_enabled(enabled) +{ + mbDownloadEnabled = enabled; + if (enabled) + { + document.getElementById('download_gpx_img').src = 'resource2/ocstyle/images/map/35x35-gpx-download.png'; + } + else + { + document.getElementById('download_gpx_img').src = 'resource2/ocstyle/images/map/35x35-no-gpx-download.png'; + } +} + +function getTimeDiff(dTime1, dTime2) +{ + return ((dTime2-dTime1)/1000).toFixed(1); +} + +function addCacheToMap(sWaypoint, nLon, nLat, nType, bOwned, bFound) +{ + if (sWaypoint == msPopupMarkerWP) + { + for (var nIndex=0; nIndex + {/literal} diff --git a/htdocs/templates2/ocstyle/map2full.tpl b/htdocs/templates2/ocstyle/map2full.tpl new file mode 100644 index 00000000..b80d1654 --- /dev/null +++ b/htdocs/templates2/ocstyle/map2full.tpl @@ -0,0 +1,1559 @@ +{*************************************************************************** +* You can find the license in the docs directory +* +* Unicode Reminder メモ +* +* TODO: +* - implement all GM-controls as GControl (tmd_*, rqc_*) +* - show wait dialog while requesting data from OC +* - save and load all search options +* - html-popup inactive +* - ignore/owned/found in post filter? +* - download as GPX etc.pp. +* - smaller icons with any caches shown +* - implement fullscreen +* - monitor and improve DB cleanup +* - review/rewrite mapsubmit_click +* - rewrite function names +* - use resultid in each map.php query +* - check if slave db connection works as expected (especially sys_repl_exclude / master connection) +* - save and load search config from different profiles that the user can modify +* - show labels inside the map +* - GPX download of current view +* - save and load current view +* - switch current options/view to search result page +***************************************************************************} +{* OCSTYLE *} + + + + + +
+ +{literal} + +{/literal} + +
+ + +
+ +{literal} + +{/literal}