Changeset 1226

Show
Ignore:
Timestamp:
09/19/10 19:05:05 (3 years ago)
Author:
d0nut
Message:

finished gmap release candidate, version 1

Location:
g-map
Files:
2 added
1 removed
13 modified
3 moved

Legend:

Unmodified
Added
Removed
  • g-map/de.xml

    r1222 r1226  
    2121                <item name="wcf.acp.group.option.user.profile.gmap.personalMap.description"><![CDATA[Kann der Benutzer eigene Karten anlegen? Wenn ja, wieviele?]]></item> 
    2222        </category> 
     23        <category name="wcf.map"> 
     24                <item name="wcf.map.copyright.small"><![CDATA[Karten Erweiterung, easy-coding.de]]></item> 
     25        </category> 
    2326</language> 
  • g-map/en.xml

    r1222 r1226  
    2121                <item name="wcf.acp.group.option.user.profile.gmap.personalMap.description"><![CDATA[Can the user add personal maps? If true, how many maps can he add?]]></item> 
    2222        </category> 
     23        <category name="wcf.map"> 
     24                <item name="wcf.map.copyright.small"><![CDATA[Map Extension, easy-coding.de]]></item> 
     25        </category> 
    2326</language> 
  • g-map/files/lib/data/gmap/GmapApi.class.php

    r1224 r1226  
    2323                $apikey = explode(":", $apikey); 
    2424                if(count($apikey) == 2) { 
    25                         $this->apikey = $apikey; 
     25                        $this->apikey = $apikey[1]; 
    2626                } 
    2727        } 
     
    4343                        return; 
    4444                } 
     45                 
     46                $res = array(); 
    4547 
    4648                $lookupstring = urlencode(StringUtil::trim($location)); 
     
    5254                $io = @fsockopen($req_url, 80, $errno, $errstr, 5 ); 
    5355                if ($io) { 
    54                         $send  = "GET /maps/geo?q=".$lookupstring."&key=".$apikey."&output=csv HTTP/1.1\r\n"; 
     56                        $send  = "GET /maps/geo?q=".$lookupstring."&key=".$this->apikey."&output=csv HTTP/1.1\r\n"; 
    5557                        $send .= "Host: maps.google.com\r\n"; 
    5658                        $send .= "Accept-Language: de, en;q=0.50\r\n"; 
  • g-map/files/lib/data/gmap/GmapCluster.class.php

    r1224 r1226  
    8181                        /* Compare against all markers which are left. */ 
    8282                        foreach ($markers as $key => $target) { 
    83                                 $pixels = $this->pixelDistance($marker['lat'], $marker['lon'], $target['lat'], $target['lon'], $zoom); 
     83                                $pixels = $this->pixelDistance($marker['lat'], $marker['lon'], $target['lat'], $target['lon'], $this->zoom); 
    8484 
    8585                                /* If two markers are closer than given distance remove */ 
    8686                                /* target marker from array and add it to cluster.        */ 
    87                                 if ($distance > $pixels) { 
     87                                if ($this->distance > $pixels) { 
    8888                                        unset($markers[$key]); 
    8989                                        $cluster[] = $target; 
  • g-map/files/lib/page/MapAjaxPage.class.php

    r1223 r1226  
    1414 */ 
    1515class MapAjaxPage extends AbstractPage { 
    16         protected $zoom; 
    17         protected $distance = 30; 
     16        protected $zoom = 0; 
     17        protected $distance = 10; 
     18        protected $bounds= array(); 
     19        protected $initialized = false; 
    1820         
    1921        protected $markers = array(); 
     
    2527                parent::readParameters(); 
    2628                 
    27                 $this->zoom = min(max(21, $_GET['zoom']), 0); 
     29                $this->zoom = max(min(21, isset($_GET['zoom']) ? $_GET['zoom'] : 0), 0); 
     30                 
     31                // ((50.08930948264218, 10.298652648925781), (50.14434619645057, 10.506362915039062)) 
     32                if(isset($_GET['bounds'])) { 
     33                        if(preg_match('\((\d+\.?\d*), (\d+\.?\d*)\), \((\d+\.?\d*), (\d+\.?\d*)\)', $_GET['bounds'], $match)) { 
     34                                $this->bounds = $match; 
     35                        } 
     36                } 
     37                 
     38                // just get bounds 
     39                $this->initialized = isset($_GET['initialized']) && $_GET['initialized']; 
    2840        } 
    2941         
     
    3951                                        Y(pt) AS lat 
    4052                        FROM            wcf'.WCF_N.'_gmap_user'; 
     53                         
     54                if(!$this->initialized) { 
     55                        $sql = 'SELECT  AVG(lon) AS lon, 
     56                                        AVG(lat) AS lat 
     57                                FROM ( 
     58                                        '.$sql.' 
     59                                ) x'; 
     60                } 
    4161 
    4262                $result = WCF::getDB()->sendQuery($sql); 
  • g-map/files/lib/system/event/listener/GMapUserPageListener.class.php

    r1222 r1226  
    1111 */ 
    1212class GMapUserPageListener implements EventListener { 
     13        protected $coordinate = null; 
     14        protected $personal_maps = array(); 
     15        protected $userID = 0; 
    1316 
    1417        /** 
     
    1619         */ 
    1720        public function execute($eventObj, $className, $eventName) { 
    18                  
    19                  
    20                 return; // TODO: disabled 
    21          
     21                $this->eventObj = $eventObj; 
     22                $this->className = $className; 
     23 
    2224                $this->$eventName(); 
    2325        } 
    2426         
    2527        protected function readData() { 
     28                $this->userID = $this->eventObj->frame->getUserID(); 
    2629                 
     30                // read user location 
     31                $sql = 'SELECT          X(pt) AS lon, 
     32                                        Y(pt) AS lat 
     33                        FROM            wcf'.WCF_N.'_gmap_user 
     34                        WHERE           userID = '.intval($this->userID); 
     35                $result = WCF::getDB()->sendQuery($sql); 
     36                $this->coordinate = WCF::getDB()->fetchArray($result); 
     37                 
     38                // read personal maps 
     39                if(false) { // TODO: feature disabled for the moment 
     40                        $sql = 'SELECT          mapID 
     41                                FROM            wcf'.WCF_N.'_gmap_personal 
     42                                WHERE           userID = '.intval($this->userID); 
     43                        $result = WCF::getDB()->sendQuery($sql); 
     44                        while ($row = WCF::getDB()->fetchArray($result)) { 
     45                                $this->personal_maps[] = $row; 
     46                        } 
     47                } 
    2748        } 
    2849         
    2950        protected function assignVariables() { 
    30  
    31                 WCF::getTPL()->assign(array( 
    32                         'user' => $user, 
    33                         'gmap_map_key' => $this->map_key 
    34                 )); 
    35  
    36                 // if user position exists 
    37                 WCF::getTPL()->append('additionalBoxes2', WCF::getTPL()->fetch('userProfileMapSide')); 
     51                if($this->coordinate) { 
     52                        WCF::getTPL()->assign(array( 
     53                                'coordinate' => $this->coordinate 
     54                        )); 
     55                        // if user position exists 
     56                        WCF::getTPL()->append('additionalBoxes2', WCF::getTPL()->fetch('userProfileMapSide')); 
     57                } 
    3858 
    3959                // if user is owner or user has personal maps 
    40                 WCF::getTPL()->append('additionalContents3', WCF::getTPL()->fetch('userProfileMapCenter')); 
     60                if(WCF::getUser()->userID == $this->userID || $this->personal_maps) { 
     61                        WCF::getTPL()->append('additionalContents3', WCF::getTPL()->fetch('userProfileMapCenter')); 
     62                } 
    4163        } 
    4264} 
  • g-map/files/style/g-map.css

    r1029 r1226  
    55 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html> 
    66 */ 
    7 #mapAdministration { 
    8         width:250px; 
    9         float:right; 
    10         text-align:right; 
    11 } 
    12 #gmapAdminButtons { 
    13         display:none; 
    14 } 
    15 #map { 
    16         color:#000000; 
    17 } 
    18 #map a { 
    19         color:#154268; 
    20 } 
    21 #map .markerLabel { 
    22         color:#ffffff; 
    23 } 
    24 .LabeledMarker_markerLabel { 
    25         color:#ffffff; 
    26 } 
    27 .gmap_b { 
    28         color:#000; 
    29         width:250px; 
    30 } 
    31 .gmap_h { 
    32         font-weight:bold; 
    33         background-color:#efefef; 
    34         background-repeat:no-repeat; 
    35         background-position:left center; 
    36         padding:5px; 
    37         padding-left:25px; 
    38         cursor:pointer; 
    39 } 
    40 #gmap_notice { 
    41         display:none; 
    42         position:absolute; 
    43         padding:8px 0px 8px 0px; 
    44         top:0px; 
    45         left:0px; 
    46         width:100%; 
    47         text-align:center; 
    48         background-color:#ffff00; 
    49         opacity:0.75; 
    50         filter:alpha(opacity=75); 
    51 } 
    52 #gmap_controls div { 
    53         position:absolute; 
    54         left:7px; 
    55         top:0px; 
    56         width:175px; 
    57         height:20px; 
    58         border:1px solid #000000; 
    59         background-color:#ffffff; 
    60         overflow:hidden; 
    61 } 
    62 #gmap_loading { 
    63         display:none; 
    64         position:absolute; 
    65         top:0px; 
    66         left:0px; 
    67         width:100%; 
    68         height:100%; 
    69         background-color:#000000; 
    70         opacity:0.45; 
    71         filter:alpha(opacity=45); 
    72 } 
    73 #gmap_loading_img, #gmap_loading_message { 
    74         display:none; 
    75         position:absolute; 
    76         top:175px; 
    77         left:0px; 
    78         width:100%; 
    79         text-align:center; 
    80         color:#ffffff; 
    81         font-size:14pt; 
    82 } 
     7 
  • g-map/install.sql

    r1223 r1226  
    22        mapID int(10) UNSIGNED NOT NULL auto_increment, 
    33        userID int(10) UNSIGNED NOT NULL DEFAULT 0, 
    4         PRIMARY KEY  (mapID), 
     4        PRIMARY KEY  (mapID) 
    55) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    66 
  • g-map/optionals/de.gmap.wbb/package.xml

    r1221 r1226  
    88                <packagedescription language="fr"><![CDATA[Ce paquet ajoute quelques optimisations WBB à la G-Map pour le WCF.]]></packagedescription> 
    99                <packagedescription language="tr"><![CDATA[Bu Paket G-Mapin Bazi Özelliklerini WBB Uyarliyor.]]></packagedescription> 
    10                 <isunique>1</isunique> 
     10                <isunique>0</isunique> 
    1111                <version>2.0.0 RC 1</version> 
    1212                <date>DATE</date> 
     
    2121        <requiredpackages> 
    2222                <requiredpackage minversion="3.1.0 RC 1">com.woltlab.wbb</requiredpackage> 
    23                 <requiredpackage minversion="1.3.0">de.gmap.wcf.data.page.map</requiredpackage> 
     23                <requiredpackage minversion="2.0.0 RC 1">de.gmap.wcf.data.page.map</requiredpackage> 
    2424        </requiredpackages> 
    2525         
     
    2727                <files>files.tar</files> 
    2828                <eventlistener>eventlistener.xml</eventlistener> 
     29                <languages languagecode="de">de.xml</languages> 
     30                <languages languagecode="en">en.xml</languages> 
    2931        </instructions> 
    3032 
  • g-map/optionals/de.gmap.wcf.data.message.bbcode.map/files/lib/data/message/bbcode/MapBBCode.class.php

    r763 r1226  
    22require_once(WCF_DIR.'lib/data/message/bbcode/BBCodeParser.class.php'); 
    33require_once(WCF_DIR.'lib/data/message/bbcode/BBCode.class.php'); 
    4 require_once(WCF_DIR.'lib/util/MapDiscover.class.php'); 
    5 require_once(WCF_DIR.'lib/util/BoundsUtil.class.php'); 
    64 
    75/** 
     
    1311 */ 
    1412class MapBBCode implements BBCode { 
    15         // map key default setting 
    16         public $map_key = MAP_API; 
    1713 
    1814        /** 
     
    8480         * e.g. Berlin deutschland 
    8581         */ 
    86         private function parseGeocoder($data, &$stream, &$zoom) { 
     82        private function parseGeocoder(&$data, &$stream, &$zoom) { 
    8783                $first = array_shift($data); 
    88  
    89                 $google = new MapDiscover(); 
    90                 $res = $google->search($first); 
    91                 $stream[] = $res['x'].','.$res['y']; 
     84                 
     85                require_once(WCF_DIR.'lib/data/gmap/GmapApi.class.php'); 
     86                $api = new GmapApi(); 
     87                $res = $api->search($first); 
     88                if($res) { 
     89                        $stream[] = $res['lat'].','.$res['lon']; 
     90                } 
    9291 
    9392                if(count($data) > 0) { 
     
    102101                $bounds = new BoundsUtil(); 
    103102                $id = rand(); 
     103 
    104104                $code = '<div id="map'.$id.'" style="width: 100%; height: 300px;"></div> 
    105105                <script src="http://maps.google.com/maps?file=api&amp;v=2.118&amp;key='.$this->map_key.'&amp;oe='.CHARSET.'" type="text/javascript"></script> 
     
    154154         */ 
    155155        public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { 
     156 
     157                // TODO: feature disabled 
     158                return $content; 
     159         
    156160                $zoom = isset($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : null; 
    157161                $content = explode("\n", StringUtil::unifyNewlines($content)); 
  • g-map/optionals/de.gmap.wcf.data.message.bbcode.map/package.xml

    r1221 r1226  
    1717        <requiredpackages> 
    1818                <requiredpackage minversion="1.0.0">com.woltlab.wcf.data.message.bbcode</requiredpackage> 
    19                 <requiredpackage minversion="1.3.0">de.gmap.wcf.data.page.map</requiredpackage> 
     19                <requiredpackage minversion="2.0.0 RC 1">de.gmap.wcf.data.page.map</requiredpackage> 
    2020        </requiredpackages> 
    2121 
  • g-map/templates/mapOverview.tpl

    r1222 r1226  
    66        {include file='gmapConstants'} 
    77        <script src="{@RELATIVE_WCF_DIR}js/gmap/Map.class.js" type="text/javascript"></script> 
     8        <script type="text/javascript" src="{@RELATIVE_WCF_DIR}js/AjaxRequest.class.js"></script> 
    89        <script type="text/javascript"> 
    910                //<![CDATA[ 
    1011                if (GMAP_API_KEY != '')  {  
    11                         document.write('<script src="http://maps.google.com/maps?file=api&amp;v=2.118&amp;hl={@$this->language->getLanguageCode()}&amp;key=' + GMAP_API_KEY + '&amp;oe={CHARSET}" type="text/javascript"><\/script>'); 
    12                         onloadEvents.push(function() { 
    13                                 if (GBrowserIsCompatible()) { 
    14                                         var gmap = new Map('{@$id}'); 
    15                                         {if $location|isset}gmap.setLocation('{$location|encodeJS}'); 
    16                                         {elseif $latitude|isset && $longitude|isset} 
    17                                                 var coordinates = new GLatLng({@$latitude}, {@$longitude}); 
    18                                                 gmap.setCoordinates(coordinates); 
    19                                         {/if} 
    20                                          
    21                                         // init route 
    22                                         var gmapRoute = new MapRoute(gmap); 
    23                                 } 
    24                         }); 
     12                        document.write('<script src="http://maps.google.com/maps?file=api&amp;v=2.118&amp;hl={@$this->language->getLanguageCode()}&amp;key=' + GMAP_API_KEY + '&amp;oe={CHARSET}" type="text/javascript"><\/script>'); 
     13                        onloadEvents.push(function() { 
     14                                if (GBrowserIsCompatible()) { 
     15 
     16                                        var AjaxMap = function(url, divID, switchable) { 
     17                                                this.url = url; 
     18                                                this.constructor(divID, switchable); 
     19 
     20                                                this.update = function() { 
     21                                                        url = this.url; 
     22                                                         
     23                                                        if(this.mapInitialized) { 
     24                                                                url += '&zoom='+this.gmap.getZoom(); 
     25                                                                url += '&bounds='+this.gmap.getBounds(); 
     26                                                                url += '&initialized=1'; 
     27                                                        } 
     28 
     29                                                        var ajaxRequest = new AjaxRequest(); 
     30                                                        ajaxRequest.openGet(url + SID_ARG_2ND, function(map) { 
     31                                                                return function() { 
     32                                                                        if(ajaxRequest.xmlHttpRequest.readyState == 4 && ajaxRequest.xmlHttpRequest.status == 200) { 
     33                                                                                var data = eval('(' + ajaxRequest.xmlHttpRequest.responseText + ')'); 
     34                                                                                var coordinates; 
     35 
     36                                                                                if(map.mapInitialized) { 
     37                                                                                        map.gmap.clearOverlays(); 
     38                                                                                        for(var i in data) { 
     39                                                                                                coordinates = new GLatLng(data[i].lat, data[i].lon); 
     40                                                                                                map.gmap.addOverlay(new GMarker(coordinates)); 
     41                                                                                        } 
     42                                                                                } else { 
     43                                                                                        coordinates = new GLatLng(data[0].lat, data[0].lon); 
     44                                                                                        map.setCoordinates(coordinates); 
     45                                                                                        map.gmap.clearOverlays(); 
     46                                                                                         
     47                                                                                        map.update(); 
     48                                                                                        map.setEvents(); 
     49                                                                                } 
     50                                                                        } 
     51                                                                }; 
     52                                                        }(this)); 
     53                                                }; 
     54                                                 
     55                                                this.setEvents = function() { 
     56                                                        GEvent.addListener(this.gmap, "moveend", function(map) { 
     57                                                                return function() { 
     58                                                                        map.update(); 
     59                                                                } 
     60                                                        }(this)); 
     61                                                } 
     62                                        }; 
     63                                        AjaxMap.prototype = new Map(); 
     64 
     65                                        gmap = new AjaxMap('index.php?page=MapAjax', 'gmap'); 
     66                                        gmap.update(); 
     67                                } 
     68                        }); 
    2569                } 
    2670                //]]> 
    2771        </script> 
    28          
    29         <script type="text/javascript" src="{@RELATIVE_WCF_DIR}js/AjaxRequest.class.js"></script> 
    3072</head> 
    31 <body> 
     73<body{if $templateName|isset} id="tpl{$templateName|ucfirst}"{/if}> 
    3274{include file="header" sandbox=false} 
    3375<div id="main"> 
    3476        <ul class="breadCrumbs"> 
    35                 <li><a href="index.php{@SID_ARG_1ST}"><img src="icon/indexS.png" alt="" /> <span>{PAGE_TITLE}</span></a> &raquo;</li> 
     77                <li><a href="index.php?page=Index{@SID_ARG_2ND}"><img src="{icon}indexS.png{/icon}" alt="" /> <span>{lang}{PAGE_TITLE}{/lang}</span></a> &raquo;</li> 
    3678        </ul> 
    3779         
    38         {if $gmap_admin}<div id="mapAdministration"> 
    39                 <a href="#" onclick="return gAdministrate(this, '{lang}wcf.map.administrateOn{/lang}', '{lang}wcf.map.administrateOff{/lang}')">{lang}wcf.map.administrateOn{/lang}</a> 
    40                 <div class="largeButtons" id="gmapAdminButtons"> 
    41                         <ul> 
    42                                 <li><a href="#" onclick="return gRequestAdd('{lang}wcf.map.markerClickToAdd{/lang}');"><img src="icon/g-map/markerAddM.png" alt="" /> <span>{lang}wcf.map.markerAdd{/lang}</span></a></li> 
    43                         </ul> 
    44                 </div> 
    45         </div>{/if} 
    46          
    47         <div class="mainHeadline" style="clear:none"> 
    48                 <img src="icon/glob48.png" alt="" title="{lang}wcf.map.copyright{/lang}" /> 
     80        <div class="mainHeadline"> 
     81                <img src="{icon}gmapL.png{/icon}" alt="" /> 
    4982                <div class="headlineContainer"> 
    50                         <h2> {lang}wcf.header.menu.map{/lang}</h2> 
    51                         <b id="gmap_usercount">...</b> {lang}wcf.map.counter_user{/lang} / <b id="gmap_markercount">..</b> {lang}wcf.map.counter_marker{/lang} 
     83                        <h2>{lang}wcf.header.menu.map{/lang}</h2> 
    5284                </div> 
    5385        </div> 
    54         <div class="border"> 
     86         
     87        {if $userMessages|isset}{@$userMessages}{/if} 
     88         
     89        <div class="border content"> 
    5590                <div class="container-1"> 
    5691                        <div style="position:relative"> 
    57                                 <!-- Map //--> 
    58                                 <div id="map" style="width: 100%; height: 500px"></div> 
    59                                  
    60                                 <!-- GroupFilter sub //--> 
    61                                 <div id="gmap_controls_sub"></div> 
    62                                  
    63                                 <!-- Controls //--> 
    64                                 <form method="post" action="" onsubmit="return false"> 
    65                                         <div id="gmap_controls"></div> 
    66                                 </form> 
    67                                  
    68                                 <!-- Messages //--> 
    69                                 <div id="gmap_notice"></div> 
    70  
    71                                 <!-- Loading //--> 
    72                                 <div id="gmap_loading">&nbsp;</div> 
    73                                 <div id="gmap_loading_message">&nbsp;</div> 
    74                                  
    75                                 <div id="gmap_loading_img"> 
    76                                         <img src="icon/g-map/loading.gif" alt="" /> 
    77                                 </div> 
     92                                <div id="gmap"><div id="gmapCanvas" style="width: 100%; height: 500px"></div></div> 
    7893                        </div> 
    7994                </div> 
    80                 <a href="http://trac.easy-coding.de/trac/g-map" class="externalURL" style="float:right">{lang}wcf.map.copyright_small{/lang}</a> 
     95                <a href="http://trac.easy-coding.de/trac/wcf/wiki/Gmap" class="externalURL" style="float:right">{lang}wcf.map.copyright.small{/lang}</a> 
    8196        </div> 
     97</div> 
    8298 
    83 </div> 
    8499{include file="footer" sandbox=false} 
    85  
    86100</body> 
    87101</html> 
  • g-map/templates/userProfileMapSide.tpl

    r1028 r1226  
    22        <div class="border"> 
    33                <div class="containerHead"> 
    4                         <div class="containerIcon"><img src="{@RELATIVE_WCF_DIR}icon/glob24.png" alt="" title="{lang}wcf.map.copyright{/lang}"/></div> 
     4                        <div class="containerIcon"><img src="{@RELATIVE_WCF_DIR}icon/mapM.png" alt="" title="{lang}wcf.map.copyright{/lang}"/></div> 
    55                        <h3 class="containerContent">{lang}wcf.user.profile.map{/lang} </h3> 
    66                </div> 
    7                 <div class="container-1"> 
    8                         <div id="map" style="width: 100%; height: 260px; overflow:hidden"></div> 
     7                <div class="container-1" id="userMap"> 
     8                        <div id="userMapCanvas" style="width: 100%; height: 260px; overflow:hidden"></div> 
    99                </div> 
    1010        </div> 
     
    1818                onloadEvents.push(function() { 
    1919                        if (GBrowserIsCompatible()) { 
    20                                 var gmap = new Map('{@$id}'); 
    21                                 gmap.setLocation('{$user->location|encodeJS}'); 
     20                                var map = new Map('userMap'); 
     21                                coordinates = new GLatLng({$coordinate.lat}, {$coordinate.lon}); 
     22                                map.setCoordinates(coordinates); 
    2223                        } 
    2324                });