[Linpha-cvs] SF.net SVN: linpha: [4766] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2007-08-20 22:19:11
|
Revision: 4766 http://linpha.svn.sourceforge.net/linpha/?rev=4766&view=rev Author: fangehrn Date: 2007-08-20 15:19:07 -0700 (Mon, 20 Aug 2007) Log Message: ----------- 2007-08-20 flo * google maps - added some basic marker/geocode functions Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/index.php trunk/linpha2/lib/plugins/maps/module.exampleMap.php trunk/linpha2/templates/default/map.head.php Added Paths: ----------- trunk/linpha2/lib/plugins/maps/LinMaps.js Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-08-19 22:48:44 UTC (rev 4765) +++ trunk/linpha2/ChangeLog 2007-08-20 22:19:07 UTC (rev 4766) @@ -1,3 +1,7 @@ +2007-08-20 flo + * google maps + - added some basic marker/geocode functions + 2007-08-19 flo * adding google maps support - modified gmapper class: increased the number of paragraphs "no image at this zoomlevel" Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2007-08-19 22:48:44 UTC (rev 4765) +++ trunk/linpha2/index.php 2007-08-20 22:19:07 UTC (rev 4766) @@ -67,12 +67,20 @@ case 'download': require_once(LINPHA_DIR.'/lib/modules/module.download.php'); break; +case 'empty': + require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); + break; + + +// plugins case 'map': + /** + * @todo check if plugin enabled + */ require_once(LINPHA_DIR.'/lib/plugins/maps/module.exampleMap.php'); break; -case 'empty': - require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); - break; + + default: require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); break; Added: trunk/linpha2/lib/plugins/maps/LinMaps.js =================================================================== --- trunk/linpha2/lib/plugins/maps/LinMaps.js (rev 0) +++ trunk/linpha2/lib/plugins/maps/LinMaps.js 2007-08-20 22:19:07 UTC (rev 4766) @@ -0,0 +1,213 @@ + +/** + * class and global definitions + */ +var LinMaps = Class.create(); +var myLinMaps; + +LinMaps.prototype = +{ + /** + * initialize() + * Constructor runs on completion of the DOM loading. + */ + initialize: function() + { + this.editMarker = false; + this.navIsHidden = false; + this.defaultMarkerZoom = 10; + }, + + /** + * Marker functions + */ + loadMarkers: function() + { + + }, + geocodeAddress: function(address) + { + if( this.editMarker ) + { + map.removeOverlay( this.editMarker ) + } + + if( address == '' ) + { + this.createEditMarker( map.getCenter() ); + } + else + { + geocoder.getLatLng( + address, + function(point) + { + if(!point) + { + alert(address + " not found"); + } + else + { + map.setCenter(point, myLinMaps.defaultMarkerZoom); + myLinMaps.createEditMarker( point ); + + $('linInputMarkerName').value = address; + } + } + ); + } + }, + createEditMarker: function( center ) + { + this.editMarker = new GMarker(center, {draggable: true}); + + /*GEvent.addListener(marker, "dragstart", function() { + map.closeInfoWindow(); + });*/ + + /*GEvent.addListener(marker, "dragend", function() { + marker.openInfoWindowHtml("Just bouncing along..."); + });*/ + + GEvent.addListener(this.editMarker, "drag", function() { + myLinMaps.updateEditMarker(); + }); + + map.addOverlay( this.editMarker ); + + this.updateEditMarker(); + }, + updateEditMarker: function() + { + if( this.editMarker ) + { + latlng = this.editMarker.getPoint(); + $('linInputLat').value = latlng.lat(); + $('linInputLon').value = latlng.lng(); + } + else + { + $('linInputMarkerName').value = ''; + $('linInputLat').value = ''; + $('linInputLon').value = ''; + } + }, + saveMarker: function(t) + { + xmlAnswer = t.responseXML.documentElement; + + if( xmlAnswer.getElementsByTagName('responseCode').item(0).firstChild.data == 'success' ) + { + map.removeOverlay( myLinMaps.editMarker ); + myLinMaps.editMarker = false; + myLinMaps.updateEditMarker(); + + myLinMaps.loadMarkers(); + } + else + { + alert(xmlAnswer.getElementsByTagName('responseMsg').item(0).firstChild.data ); + } + }, + + + /** + * Thumbnail functions + */ + toggleNav: function() + { + + if( this.navIsHidden ) + { + // restore save margin + $('gmapper_map').style.marginRight = $('linDivMapNav').style.marginRight; + $('linDivMapNav').style.marginRight = 0; + + Element.show('linDivMapNav'); + + this.navIsHidden = false; + } + else + { + Element.hide('linDivMapNav'); + + // backup current margin + $('linDivMapNav').style.marginRight = $('gmapper_map').style.marginRight; + + $('gmapper_map').style.marginRight = 7; + + this.navIsHidden = true; + } + + // update google map size + map.checkResize(); + } + + + + + + + + +} // end class LinMaps + +function linOnResizeWrapper() +{ + myLinGlobal.setWindowSize(); + var newHeight = myLinGlobal.linInnerHeight - $('linDivMain').offsetTop - 80; + if(newHeight < 100) + { + newHeight = 100; + } + + $('linDivMapNav').style.height = newHeight; + $('linDivMapMain').style.height = newHeight; + + + /** + * tempoarely set the map heigth to a small value (zero does not work!) + * in IE setMainHeight() would not work while reducing the window size + * because IE takes always as much space as he actually needs ignoring + * the height attribute + */ + + /*$('linDivMapNav').style.height = 10; + $('linDivMapMain').style.height = 10; + + myLinGlobal.setMainHeight(); + + $('linDivMapMain').style.height = $('linDivMain').offsetHeight - $('linDivMapTop').offsetHeight - $('linDivMapBottom').offsetHeight - 5;*/ + + /** + * set also height of the navigation bar + * overflow:auto does not work in IE with height: 100% + */ + /*$('linDivMapNav').style.height = $('linDivMapMain').style.height;*/ + + // resize google map itself also + map.checkResize(); +} + +/** + * initLinMaps() + * + * create the class object + */ +function initLinMaps() +{ + myLinMaps = new LinMaps(); + + linEnableOnResize(); + linOnResizeWrapper(); + +} + +//initLinMaps(); +Event.observe(window, 'load', initLinMaps, false); + +// prevent memory leaks in internet explorer +Event.observe(window, 'unload', GUnload, false); + + + Modified: trunk/linpha2/lib/plugins/maps/module.exampleMap.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.exampleMap.php 2007-08-19 22:48:44 UTC (rev 4765) +++ trunk/linpha2/lib/plugins/maps/module.exampleMap.php 2007-08-20 22:19:07 UTC (rev 4766) @@ -1,6 +1,80 @@ <?php +/* + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * Google Maps + * @package Plugins + */ +if(!defined('LINPHA_DIR')) { exit(1); } + + require_once(LINPHA_DIR."/lib/plugins/maps/gmapper1/class.gmapper.php"); +if(isset($_GET['xml'])) +{ + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + echo '<root>'."\n"; + + if(isset($_POST['cmd'])) + { + switch($_POST['cmd']) + { + case 'loadMarker': + break; + + case 'saveMarker': + + if( !isset($_POST['linInputMarkerName']) OR empty($_POST['linInputMarkerName'])) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.i18n("Error: no title specified").'</responseMsg>'."\n"; + } + elseif( !isset($_POST['linInputLat']) OR empty($_POST['linInputLat']) + OR !isset($_POST['linInputLon']) OR empty($_POST['linInputLon'])) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.i18n("Error: Missing Lat/Lon values").'</responseMsg>'."\n"; + } + else + { + /** + * @todo save marker in db + */ + /* + $_POST['linInputMarkerName'] + floatval($_POST['linInputLat']) + floatval($_POST['linInputLon']) + */ + + echo '<responseCode>success</responseCode>'."\n"; + } + + break; + } + } + + echo '</root>'."\n"; + exit(); +} + if(isset($_GET['albId'])) { $albId = intval($_GET['albId']); } @@ -27,20 +101,7 @@ ob_start(); ?> - <div id="linDivMapTop"> - <?php - echo i18n("Please select the album to show in Google Maps:"); - echo '<br /><br /><a href="'.LINPHA_LINK.'&linCat=map&albId=0">'.i18n("All albums").'</a><br />'; - - foreach($parentIds as $id=>$value) - { - echo '<a href="'.LINPHA_LINK.'&linCat=map&albId='.$id.'">'; - echo implode( '/', LinSql::getFullFilenameFromId($id) ); - echo '</a><br />'; - } - ?> - <br /> - </div> + <div id="linDivMapTop"></div> <div id="linDivMapMain" style="height: 475px;"> <div id="linDivMapNav" style="width: 155px; height: 475px; float: right; overflow: auto; padding-left: 2px; padding-right: 1px;"> @@ -56,6 +117,31 @@ </div> <div id="linDivMapBottom"> + + <input type="text" id="linInputAddress" size="30"> + <input type="button" onclick="myLinMaps.geocodeAddress( $('linInputAddress').value )" value="<?php echo i18n("Geocode"); ?>"> + <br /><br /> + + <div id="linDivEditMarker" style="border: 1px solid black; width: 550px; padding: 3px;"> + <form action="" method="POST" onsubmit="myLinGlobal.AjaxPost(Form.serialize(this),myLinMaps.saveMarker); return false;"> + <label for="linInputMarkerName" style="display: block; float: left; width: 150px;">Marker Name: + </label><input type="text" id="linInputMarkerName" name="linInputMarkerName" size="30" /><br /> + <label for="linInputLat" style="display: block; float: left; width: 150px;">Lat + </label><input type="text" id="linInputLat" name="linInputLat" size="10" /><br /> + <label for="linInputLon" style="display: block; float: left; width: 150px;">Lon: + </label><input type="text" id="linInputLon" name="linInputLon" size="10" /><br /> + <input type="submit" value="<?php echo i18n("Save"); ?>" /> + <input type="hidden" name="cmd" value="saveMarker" /> + </form> + </div> + + + + <br /><br /><br /> + + + <?php + /* <input type="text" id="adresse" size="30"> <input type="button" onclick="<?php $GLOBALS['linpha']->template->output['googleMap']->geocode( "getAdress()", "otherMarker", array(LINPHA_CLIENT."/lib/plugins/maps/gmapper1/dash.png",32,32)); ?>" value="Geocode"> <br> @@ -66,7 +152,58 @@ "Muenchen", "otherMarker", array(LINPHA_CLIENT."/lib/plugins/maps/gmapper1/rot.png",20,34), 10); ?>">München</a><br /> <a href="javascript:void(0)" onclick="<?php $GLOBALS['linpha']->template->output['googleMap']->geocode( "Koelner Dom", "otherMarker", array(LINPHA_CLIENT."/lib/plugins/maps/gmapper1/gruen.png",20,34), 17); ?>">Kölner Dom</a> + + */ + + + + + + echo i18n("Please select the album to show in Google Maps:"); + echo '<br /><br /><a href="'.LINPHA_LINK.'&linCat=map&albId=0">'.i18n("All albums").'</a><br />'; + + foreach($parentIds as $id=>$value) + { + echo '<a href="'.LINPHA_LINK.'&linCat=map&albId='.$id.'">'; + echo implode( '/', LinSql::getFullFilenameFromId($id) ); + echo '</a><br />'; + } + ?> + <br /> + + <div> + Legend:<br /> + (red) current marker<br /> + (yellow) location marker<br /> + (blue) location marker with assigned albums<br /> + (green) location marker with assigned images (GPS)<br /> + (pink) images<br /> + </div> + + <div> + Create marker:<br /> + 1. Enter address or just press "Geocode"<br /> + 2. Drag the marker to fine adjust<br /> + 3. Check marker name<br /> + 4. Press "Save"<br /> + <br /> + Assign albums:<br /> + 1. Click on a marker<br /> + 2. Press "Assign album"<br /> + 3. Choose album and press "Save"<br /> + 4. Repeat for multiple albums<br /> + <br /> + Assign images to an album marker:<br /> + This is done automatically. But it's required that your images have the + GPS information stored inside. You will need a GPS Data Logger to do this + automatically. It is also possible do it manually. Robogeo is a tool, but + it is not free. + </div> + + </div> + + <?php $GLOBALS['linpha']->template->output['googleMap']->map( $zoom = 4, @@ -149,6 +286,7 @@ $linpha->template->setModuleName('default'); $linpha->template->overrideModule('head','map'); $linpha->template->URL_full = LINPHA_LINK.'&linCat=map'; +$linpha->template->URL_base = LINPHA_LINK.'&linCat=map'; $linpha->template->output['title'] = i18n("Google Maps"); include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); Modified: trunk/linpha2/templates/default/map.head.php =================================================================== --- trunk/linpha2/templates/default/map.head.php 2007-08-19 22:48:44 UTC (rev 4765) +++ trunk/linpha2/templates/default/map.head.php 2007-08-20 22:19:07 UTC (rev 4766) @@ -2,74 +2,13 @@ $linTpl->output['googleMap']->headjs(); ?> <script type="text/javascript" language="JavaScript" src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/maps/gmapper1/bodyjs.js"></script> -<script language="JavaScript" type="text/javascript"> - -var linNavIsHidden = false; -function linToggleNav() -{ - - if( linNavIsHidden ) - { - // restore save margin - $('gmapper_map').style.marginRight = $('linDivMapNav').style.marginRight; - $('linDivMapNav').style.marginRight = 0; - - Element.show('linDivMapNav'); - - linNavIsHidden = false; - } - else - { - Element.hide('linDivMapNav'); - - // backup current margin - $('linDivMapNav').style.marginRight = $('gmapper_map').style.marginRight; - - $('gmapper_map').style.marginRight = 7; - - linNavIsHidden = true; - } - - // update google map size - map.checkResize(); -} - - - -function linOnResizeWrapper() -{ - /** - * tempoarely set the map heigth to a small value (zero does not work!) - * in IE setMainHeight() would not work while reducing the window size - * because IE takes always as much space as he actually needs ignoring - * the height attribute - */ - - $('linDivMapNav').style.height = 10; - $('linDivMapMain').style.height = 10; - - myLinGlobal.setMainHeight(); - - $('linDivMapMain').style.height = $('linDivMain').offsetHeight - $('linDivMapTop').offsetHeight - $('linDivMapBottom').offsetHeight - 5; - - /** - * set also height of the navigation bar - * overflow:auto does not work in IE with height: 100% - */ - $('linDivMapNav').style.height = $('linDivMapMain').style.height; - - // resize google map itself also - map.checkResize(); -} - -function initLinMap() -{ - linEnableOnResize(); - linOnResizeWrapper(); -} -Event.observe(window, 'load', initLinMap, false); - -// prevent memory leaks in internet explorer -Event.observe(window, 'unload', GUnload, false); -</script> - \ No newline at end of file +<script type="text/javascript" language="JavaScript" src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/maps/LinMaps.js"></script> +<script language="JavaScript" type="text/javascript"> +var xmlUrl = '<?php echo linConvertAmp($linTpl->URL_base); ?>'; +var imageSrc = '<?php echo LINPHA_CLIENT.'/get_image.php?linId='; ?>'; +var thumbSrc = '<?php echo LINPHA_CLIENT.'/get_thumb.php?linId='; ?>'; +var maxImageWidth = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_width']; ?>; +var maxImageHeight = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_image_height']; ?>; +var maxThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; ?>; +var displayThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>; +</script> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |