Author: simoneg
Date: Thu Dec 17 11:30:41 2009
New Revision: 891652

URL: http://svn.apache.org/viewvc?rev=891652&view=rev
Log:
LABS-503 : new map website support

Added:
    labs/magma/trunk/website-maps-google/pom.xml
    labs/magma/trunk/website-maps-google/src/
    labs/magma/trunk/website-maps-google/src/main/
    labs/magma/trunk/website-maps-google/src/main/java/
    labs/magma/trunk/website-maps-google/src/main/java/org/
    labs/magma/trunk/website-maps-google/src/main/java/org/apache/
    labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/
    labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/
    
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/
    
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
    
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
    labs/magma/trunk/website-maps-google/src/main/resources/
    labs/magma/trunk/website-maps-google/src/main/resources/META-INF/
    
labs/magma/trunk/website-maps-google/src/main/resources/META-INF/magma.default.properties
    labs/magma/trunk/website-maps-google/src/main/resources/org/
    labs/magma/trunk/website-maps-google/src/main/resources/org/apache/
    labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/flat-mark.png
   (with props)
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/icons.png
   (with props)
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.css
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.html
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.css
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.html
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js
    
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/ui-icons.png
   (with props)
    labs/magma/trunk/website-maps-google/src/test/
    labs/magma/trunk/website-maps-google/src/test/java/
    labs/magma/trunk/website-maps-google/src/test/resources/
Modified:
    labs/magma/trunk/website-maps-google/   (props changed)

Propchange: labs/magma/trunk/website-maps-google/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Dec 17 11:30:41 2009
@@ -0,0 +1,7 @@
+.classpath
+.project
+.settings
+bin
+classes
+target
+target-eclipse

Added: labs/magma/trunk/website-maps-google/pom.xml
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/pom.xml?rev=891652&view=auto
==============================================================================
--- labs/magma/trunk/website-maps-google/pom.xml (added)
+++ labs/magma/trunk/website-maps-google/pom.xml Thu Dec 17 11:30:41 2009
@@ -0,0 +1,30 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <parent>
+    <artifactId>magma-parent</artifactId>
+    <groupId>org.apache.magma</groupId>
+    <version>3</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.magma</groupId>
+  <artifactId>website-maps-google</artifactId>
+  <name>Magma Website Google Maps</name>
+  <version>0.0.3-SNAPSHOT</version>
+  <packaging>magma</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.magma</groupId>
+      <artifactId>beans-map</artifactId>
+      <version>0.0.3-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.magma</groupId>
+      <artifactId>foundation-website</artifactId>
+      <version>0.0.3-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.magma</groupId>
+      <artifactId>website-jquery</artifactId>
+      <version>0.0.3-SNAPSHOT</version>    
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Added: 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlFormPiece.java
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1,71 @@
+package org.apache.magma.website.htmlpieces;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.magma.beans.MagMapBean;
+import org.apache.magma.beans.PropertyInfo;
+import org.apache.magma.settings.Settings;
+import org.apache.magma.validation.CompoundValidator;
+import org.apache.magma.validation.Validator;
+import org.apache.magma.validation.validators.MapBeanValidator;
+import org.apache.magma.website.Head;
+
+public class MapBeanHtmlFormPiece implements HtmlFormPiece<MagMapBean>, 
PropertyAwareHtmlPiece {
+
+       public String createFormInput(MagMapBean value, String id) {
+               StringBuilder ret = new StringBuilder();
+               String val = "null";
+               String md = "";
+               if (value != null) {
+                       val = "map" + value.hashCode();
+                       val = val.replace('-', '_');
+                       md = value.getValue();
+               }
+               ret.append("<input type=\"hidden\" id=\"" + id + "\" name=\"" + 
id + "\" value=\"" + StringEscapeUtils.escapeXml(md) + "\"/>");
+               ret.append("<div class=\"MagmaMapEdit\" id=\"edit" + val + 
"\"></div>");
+               ret.append("<div class=\"MagmaMapListContainer\">");
+               ret.append("<table class=\"MagmaMapList\" id=\"edit" + val + 
"list\"></table>");
+               ret.append("</div>");   
+               return ret.toString();
+       }
+
+       public HtmlFormPiece<MagMapBean> createInputFor(Class<? extends 
MagMapBean> clazz) {
+               return new MapBeanHtmlFormPiece();
+       }
+
+       public void formHead(MagMapBean value, String id, Head head) {
+               head.addJQuery();
+               
head.addExternalScript("http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=";
 + Settings.get("google.maps.key"));             
+               head.addExternalScript("magma:/common/maps/mapDisplay.js");
+               head.addExternalScript("magma:/common/maps/mapEditor.js");
+               head.addCss("magma:/common/maps/mapEditor.css");
+               String val = "null";
+               if (value != null) {
+                       val = "map" + value.hashCode();
+                       val = val.replace('-', '_');
+               }
+               PropertyInfo property = getProperty();
+               String options = null;
+               MapBeanValidator validator = null;
+               CompoundValidator cval = property.getValidator();
+               if (cval != null) {
+                       validator = (MapBeanValidator) 
cval.getValidator(MapBeanValidator.class);
+                       if (validator != null) {
+                               options = "{";
+                               options += "polylines:" + 
validator.isPermitLines() + ",";
+                               options += "markers:" + 
validator.isPermitMarkers() + ",";
+                               options += "routes:" + 
validator.isPermitRoutes() + ",";
+                               options += "polygons:" + 
validator.isPermitPolygons() + ",";
+                               options += "autocenter: true,";
+                               options += "defaultcontrols: true";
+                       }
+               }
+
+               head.addRawScript("init-edit-" + val, "function initedit" + val 
+ "() { new MapEditor('edit" + val + "','edit" + val + "list','" + id + "'" + 
(options == null ? "" : (",'" + options+ "'")) + "); }");
+               head.addDoOnload("initedit" + val);             
+       }
+
+       public boolean handles(Class<?> clazz) {
+               return MagMapBean.class.isAssignableFrom(clazz);
+       }
+
+}

Added: 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1,44 @@
+package org.apache.magma.website.htmlpieces;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.magma.beans.MagMapBean;
+import org.apache.magma.settings.Settings;
+import org.apache.magma.website.Head;
+
+public class MapBeanHtmlOutputPiece implements HtmlOutputPiece<MagMapBean> {
+
+       public HtmlOutputPiece<MagMapBean> createFor(Class<? extends 
MagMapBean> clazz) {
+               return this;
+       }
+
+       public boolean outputs(Class<?> clazz) {
+               return MagMapBean.class.isAssignableFrom(clazz);
+       }
+
+       public void head(MagMapBean value, Head head) {
+               head.addJQuery();
+               
head.addExternalScript("http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=";
 + Settings.get("google.maps.key"));             
+               head.addExternalScript("magma:/common/maps/mapDisplay.js");
+               head.addCss("magma:/common/maps/mapDisplay.css");
+               String val = "null";
+               String md = "";
+               if (value != null) {
+                       val = "map" + value.hashCode();
+                       val = val.replace('-', '_');
+                       md = value.getValue();
+               }
+               head.addRawScript("init-" + val, "function init" + val + "() { 
new MagMap().init('" + val + "','" + StringEscapeUtils.escapeJavaScript(md) + 
"'); }");
+               head.addDoOnload("init" + val);
+       }
+
+       public String output(MagMapBean value) {
+               // TODO support static maps here
+               String val = "null";
+               if (value != null) {
+                       val = "map" + value.hashCode();
+                       val = val.replace('-', '_');
+               }
+               return "<div class=\"MagmaMap\" id=\"" + val + "\"/>";
+       }
+
+}

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/META-INF/magma.default.properties
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/META-INF/magma.default.properties?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/resources/META-INF/magma.default.properties
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/resources/META-INF/magma.default.properties
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1,16 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+#contributor license agreements.  See the NOTICE file distributed with
+#this work for additional information regarding copyright ownership.
+#The ASF licenses this file to You under the Apache License, Version 2.0
+#(the "License"); you may not use this file except in compliance with
+#the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing, software
+#distributed under the License is distributed on an "AS IS" BASIS,
+#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#See the License for the specific language governing permissions and
+#limitations under the License.
+org.apache.magma.website.htmlpieces.HtmlOutputPiece.maps=org.apache.magma.website.htmlpieces.MapBeanHtmlOutputPiece
+org.apache.magma.website.htmlpieces.HtmlFormPiece.maps=org.apache.magma.website.htmlpieces.MapBeanHtmlFormPiece
\ No newline at end of file

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/flat-mark.png
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/flat-mark.png?rev=891652&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/flat-mark.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/icons.png
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/icons.png?rev=891652&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/icons.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.css
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.css?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.css
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.css
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1 @@
+.MagmaMap { width: 100%; height: 300px }
\ No newline at end of file

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.html
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.html?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.html
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.html
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1,21 @@
+<html>
+       <head>
+               <script type="text/javascript" 
src="http://maps.google.com/maps?file=api&v=2&sensor=false";></script>
+               <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js";></script>
+               <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js";></script>
+               <script type="text/javascript" src="mapDisplay.js"></script>
+               <style>
+                       #map { width: 88%; height: 500px; float: left; }
+               </style>
+       </head>
+       <body>
+               <input type="text" id="content" name="content" style="width: 
100%" 
value='route;0!41.911587235658416,12.50993013381958;41.91270500650227,12.506883144378662;41.917606998887024,12.500832080841064;41.92954903927401,12.492892742156982;41.93093787480193,12.490532398223877;41.931241179687376,12.495532035827637;!{zoomFactor:
 16, numLevels: 4, 
levels:"b...@bbbb?@?...@??@?...@???@b...@??bb@b...@???@?...@??@?...@??@??...@???@?????B",
 
points:"szx~fyijkaxa~...@bf@ahpj??k...@??ykrnkg`jwdlo_ajebpm@vb{kzksaxaeadbqciaqfwa...@gqgi@bubc...@icuoza??gatk@z...@f@_...@hbcr@FhA??NbCuBV??tBWX|c...@\\d@t@|j...@t@yAXfBLTZP^C|a...@lxd@{fde...@scracbyiubkh@q...@qyce@_fqdsh...@b~beaxyfy?objmaz_af@q...@x@eB"}>'/>
+               <input type="submit" value="Create display map" onclick="new 
MagMap().init('map', $('#content')[0].value)"/>
+               <div id="map"></div>
+               <script>
+                 /*new 
MagMap().init('map','route;0!45.413394446947535,9.26422119140625;45.325116643332684,9.451675415039062;45.188812246819055,9.634323120117188;45.06285162902221,9.702987670898438;44.98325649627403,9.814224243164062;44.89868701215517,9.961166381835938;44.835421613637564,10.17059326171875;!{zoomFactor:
 16, numLevels: 4, 
levels:"b????????????????...@?????????????????????@??...@??@?...@????????@?@@?...@???@??a?...@?@?...@?@?...@???@?...@?@?...@?????bb??@?...@?????@?...@??????@???????...@???@??...@??@??????...@???@?...@??@????...@????@@?...@?@?...@????bb?????@?...@????????a?????????@??...@?????@?...@????a??@?...@????????@?...@????@@?...@??????@?...@???@?...@?bb@??...@???????@?????...@????a??????????????????????????????????????????????????bb???@?...@???????@?...@??@???@@????????????...@????@?...@??@?????@@@BB@@@?...@??a??@?...@????????a?@?...@???@?...@??@?...@????@?????B",
 
points:"oxdtga...@n_@e...@oqhqlsctx@]...@m@`...@g@d...@iazq@ct@|rmtrfkfpfsejaoapeyf~dmgvb{bnr\\\\...@i]kgh@_ab_auka...@a@v...@san@x...@mxo@d...@fawbba@lm...@ynp
 
vifwm...@xt@s_afq...@a@n...@[p@o...@f`@w...@^keegdfcuj~he\\\\hakd`@{...@hmsq`aeanepacbvc{ergdsektdmf`w{ujcsdbk@c...@{bdb{glesrhdinn@gAtJ{KjEoF|c_dvdmkl[vuxbskpc}oa...@zkd@gzf...@uj`@{e~...@fdgpbgswpdqkfng]aabg@_lgbup_...@ioi@cdibsh]iccaq\\\...@pdoo@daii`...@fesqff_v~dmpba}ffu@??xb{s\\\\...@qclmba{cvny\\\\|ciitage`asdrdqo~aqhza...@gabcedbccb`bs@t...@rg_a|NoAzHaA|CiA|@g...@~aqa|agb~b...@{avdeljauctiopxgolpakcva_etfeuh@k...@wdtja~@t...@oba{c|e...@ddax|b_zv...@ifnod@yB]sFnAqCNc@@q...@v@kBzNyXrOi[tBuDjCsDfVsUthCqaCp|@m...@flqmpdqehvcyfiukhtkg@xAyD|y...@pcyelacbfeoejb}a~bwanewbjwcnrsilhciarf@k...@czxbs@pCO|f...@~a{@lbmbpu...@mcvdirf@w...@obbjwnzakb`a_bzdgejtipniumlbudvbidjbeftaqf???[ddcrjb}mhamghaaej@iaroqw~b...@ea~o{pfe_f|@a@|c...@pbeclczbac@mxdkexgzbkb^...@peidxcfut@i...@tqil`ae@jHaApCUlGuA|b...@nfua|qcilnoibewczczbw...@_xf[{rhiadvbk@f...@gm~fgbjby@nDuBjHgG|[g]ddqclcibhgec~gibhfg...@mgbg]felper@dena...@zat@hH|blpvexa\\\\bfjn...@qbng@bcyvcmatiqgrgeehcob...@f^ihdbhlujdragrao@pOyJfGgDtAY|bm^k...@vk@l...@scxjek@hCwJrA
 
sC`ByCfBcCtGoF|[...@[r@?...@jtc`bfc@ly`czb??rq...@p@lH|j...@inb\\\\b@vtob]gupbqilg?klaccfaea`hcdrjhk?qxpgi~dec...@fbwfdwa`@?...@vldzdvdpqzm@?sj[fb...@kd[iqxf{lxjgsnmzbkenibwgixe{j^yax?lu@[ksta}apka_d...@bcqftc@ztr?p...@l_agaap@ebby`bycf...@poe[fj@w...@wrbee?c@pmk...@svafekitfomtmmypdmh|ggmtki...@cdabdshvdoh??veejligqdjwst@saxrewfciexc...@ebveanceovb_f|@s...@sc|@}EpF_]lA_DdN}X|y...@fb_e|pq]lgxa...@g@`wquvm}up...@jaucbhko|Qg_@|ior~jesxnkzje}jxc...@lb@]...@yy|b_fbfujz...@^]l@cji...@?`aw@lm_[hfyop...@_hz@wvdnay~hyptf{...@ega~]it@n...@ega~f~f|e_kkama??jalahjurofggde_jtaidx...@bisuf@g...@urc~e@qfc~...@\\\\ecfwbs{d]}b_@_BaC{ISkB?eCfE{|@t...@ql|c...@rwbtyjjw@r...@va_nzkbfto~@xaeefd{efd{cjcwa~dgb`v_kzaca`aoa~dsgbdsird}gv...@vc_op@eeh...@get@kCnDiHhAmCpAkFdC{L|v...@edez@wh`cgknfqxh...@rryda"}>')*/
+                 /*new MagMap().init('map','route;0!;!{zoomFactor: 16, 
numLevels: 4, levels:"b...@?????b", 
points:"gy|~Fga}kA_LvAeB_PDUYoBKOcC}KoAaI"}>')*/
+               </script>
+       </body>
+
+</html>
\ No newline at end of file

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1,278 @@
+MagMap = function() {
+       this.map = null;
+       this.geometries = {};
+       this.shared_bounds = null;
+       this.defaultColor = "#FF00FF";
+};
+
+MagMap.POINT = 'point';
+MagMap.LINE = 'line';
+MagMap.POLY = 'poly';
+MagMap.ROUTE = 'route';
+
+MagMap.prototype.init = function(id, geometries, options) {
+       this.dom = {
+               mapDiv: $("#" + id),
+               markerDivs: [],
+       }
+       this.parseGeometries(geometries);
+         for (var geomkey in this.geometries) {
+                 this.geometries[geomkey].color = this.defaultColor;
+         }
+         if (!options) {
+                 this.options = {
+                                 defaultcontrols: true,
+                                 autocenter: true,
+                                 center: "0,0",
+                                 zoom: 2
+                 };
+         } else {
+                 this.options = options;
+         }
+       this.createMap();
+}
+
+MagMap.prototype.createMap = function() {
+         var me = this;
+
+         
+         
+         this.map = new GMap2(this.dom.mapDiv[0], 
+                       {googleBarOptions:
+                               {       showOnLoad: true, resultList: 
G_GOOGLEBAR_RESULT_LIST_SUPPRESS, 
+                                       onGenerateMarkerHtmlCallback : 
+                                               function(marker, html, result) {
+                                                       // modifies the default 
marker popup
+                                                       return 
me.extendMarker(me, marker, html, result);
+                                               }
+                               }               
+                       }
+         );
+         
+         var mapbounds = null;
+         for (var geomkey in this.geometries) {
+                 if (mapbounds == null) mapbounds = new GLatLngBounds();
+                 var geom = this.geometries[geomkey];
+                 var ovl = geom.overlay;
+                 if (ovl == null) {
+                         ovl = geom.createOverlay();
+                 }
+                 this.map.addOverlay(ovl);
+                 if (ovl instanceof GMarker) {
+                         mapbounds.extend(ovl.getLatLng())
+                 } else {
+                         var geombounds = ovl.getBounds();
+                         if (geombounds != null) {
+                                 mapbounds.extend(geombounds.getSouthWest());
+                                 mapbounds.extend(geombounds.getNorthEast());
+                         }
+                 }
+         }
+         if (this.options.autocenter && mapbounds != null) {
+                 this.map.setCenter(mapbounds.getCenter(), 
this.map.getBoundsZoomLevel(mapbounds)); 
+         } else {
+                 var mapcenter = null;
+                 if (this.options.center) {
+                         var ll = this.options.center.split(",");
+                         mapcenter = new GLatLng(ll[0], ll[1]);
+                 } else {
+                         mapcenter = new GLatLng(0,0);
+                 }
+                 this.map.setCenter(mapcenter);
+         }
+         if (this.options.defaultcontrols) {
+                 this.map.addControl(new GLargeMapControl());
+                 this.map.addControl(new GMapTypeControl());
+         }
+         
+         // Create a base icon for all of our markers that specifies the
+         // shadow, icon dimensions, etc.
+         var icon = new GIcon(G_DEFAULT_ICON);
+         //icon.image = 
'http://chart.apis.google.com/chart?cht=mm&chs=32x32&chco=77D5F7,0078AE,77D5F7&ext=.png';
+         icon.iconSize = new GSize(32, 32);
+         icon.shadowSize = new GSize(51, 32);
+         icon.iconAnchor = new GPoint(16, 32);
+         icon.infoWindowAnchor = new GPoint(16, 2);
+         icon.infoShadowAnchor = new GPoint(18, 25);
+         this.icon = icon;
+
+};
+
+MagMap.prototype.parseGeometries = function(geometries) {
+       var defs = geometries.split('>');
+       for (var i = 0; i < defs.length; i++) {
+               if (defs[i].length > 0) {
+                       var geom = new Geometry();
+                       geom.parse(defs[i]);
+                       this.addGeometry(geom);
+               }
+       }
+}
+
+
+MagMap.prototype.addGeometry = function(geom) {
+       if (this.map != null) {
+               this.map.addOverlay(geom.createOverlay());
+       }
+       this.geometries[geom.key] = geom;
+}
+
+
+function Geometry() {
+       this.key = '';
+       this.coordinates = [];
+       this.type = '';
+       this.progressive = 0;
+       this.color = '';
+       this.magMap = null;
+       this.overlay = null;
+}
+
+Geometry.prototype.parse = function(spec) {
+       var parts = spec.split("!");
+       this.key = "overlay-" + new Date().getTime() + (Geometry.prog++);
+       this.parsePreambol(parts[0]);
+       this.parseCoordinates(parts[1]);
+       if (parts.length == 3)
+               this.parseAdditional(parts[2]);
+}
+
+Geometry.prototype.parsePreambol = function(spec) {
+       var parts = spec.split(";");
+       this.type = parts[0];
+}
+
+Geometry.prog = 0;
+
+Geometry.prototype.parseCoordinates = function(spec) {
+       var coordSpecs = spec.split(";");
+       for (var i = 0; i < coordSpecs.length; i++) {
+               if (coordSpecs[i].length > 0) {
+                       var parts = coordSpecs[i].split(",");
+                       this.coordinates.push({lat : parts[0], lng: parts[1]});
+               }
+       }
+}
+
+Geometry.prototype.parseAdditional = function(spec) {
+       if (spec.length == 0) return;
+       var parsed = eval("(" + spec + ")");
+       for (var name in parsed) {
+               if (!this[name])
+                       this[name] = parsed[name];
+       }
+}
+
+Geometry.prototype.create = function(type, coordinates, key) {
+       if (!key) {
+               var newDate = new Date();
+               this.key = "overlay-" + newDate.getTime() + (Geometry.prog++);
+       } else {
+               this.key = key;
+       }
+       this.type = type;
+       this.coordinates = coordinates; 
+}
+
+Geometry.prototype.createOverlay = function() {
+       if (this.overlay && this.overlay != null) return this.overlay;
+       var overlay;
+       if (this.type == 'point') {
+               overlay = new GMarker(new GLatLng(this.coordinates[0].lat, 
this.coordinates[0].lng), this.getMarkerProperties());
+       } else if (this.type == 'line' || this.type == 'poly' || this.type == 
'route') {
+               var latlngs = [];
+               for (var i = 0; i < this.coordinates.length; i++) {
+                       latlngs.push(new GLatLng(this.coordinates[i].lat, 
this.coordinates[i].lng));
+               }
+               if (this.type == 'line') {
+                       overlay = new GPolyline(latlngs, this.color);
+               } else if (this.type == 'poly') {
+                       overlay = new GPolygon(latlngs, this.color, 2, 0.7, 
this.color, 0.2);
+               } else if (this.type == 'route') {
+                       overlay = new DirectionsPolyline(this);
+               }
+       }
+       this.overlay = overlay;
+       return overlay;
+}
+
+Geometry.prototype.coordsAsStringArray = function() {
+       var ret = [];
+       for (var i = 0; i < this.coordinates.length; i++) {
+               ret.push(this.coordinates[i].lat + "," + 
this.coordinates[i].lng);
+       }
+       return ret;
+}
+
+Geometry.prototype.getMarkerProperties = function() {
+       return {};
+}
+
+DirectionsPolyline = function(geometry) {
+       this.geometry = geometry;
+       this.directions = new GDirections();
+       this.delegateOverlay = null;
+       this.map = null;
+       this.removed = false;
+       if (geometry.points) {
+               this.delegateOverlay = GPolyline.fromEncoded({color: 
this.geometry.color, points: geometry.points, zoomFactor: geometry.zoomFactor, 
levels: geometry.levels, numLevels: geometry.numLevels});
+       } else {
+               
this.directions.loadFromWaypoints(geometry.coordsAsStringArray(), {getPolyline: 
true});
+       }
+       var me = this;
+       GEvent.addListener(this.directions, 'load', function() {
+               me.loaded();
+       });
+}
+
+DirectionsPolyline.prototype = new GOverlay();
+
+DirectionsPolyline.prototype.initialize = function(map) {
+       if (!this.map && this.delegateOverlay) {
+               map.addOverlay(this.delegateOverlay);
+       }
+       this.map = map;
+}
+
+DirectionsPolyline.prototype.remove = function() {
+       if (this.delegateOverlay) {
+               this.map.removeOverlay(this.delegateOverlay);
+       }
+       this.delegateOverlay = null;
+       this.removed = true;
+}
+
+DirectionsPolyline.prototype.redraw = function(force) {
+       if (this.delegateOverlay) {
+               this.delegateOverlay.redraw(force);
+       } 
+}
+
+DirectionsPolyline.prototype.getKml = function() {
+       if (this.delegateOverlay) {
+               return this.delegateOverlay.getKml();
+       } else return null;
+}
+
+DirectionsPolyline.prototype.copy = function() {
+       if (this.delegateOverlay) {
+               return this.delegateOverlay.copy();
+       } else return null;
+}
+
+DirectionsPolyline.prototype.loaded = function() {
+       if (this.removed) return;
+       if (this.delegateOverlay) {
+               this.map.removeOverlay(this.delegateOverlay);
+               this.doInitialize = true;
+       }
+       this.delegateOverlay = this.directions.getPolyline();
+       if (this.map) this.map.addOverlay(this.delegateOverlay);
+}
+
+DirectionsPolyline.prototype.getBounds = function() {
+       if (this.delegateOverlay) return this.delegateOverlay.getBounds();
+       return null;
+}
+
+

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.css
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.css?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.css
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.css
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1,35 @@
+.icon { float:left; position:absolute; cursor:pointer; cursor:hand; 
padding:3px; }
+.ui-icon { display: block; text-indent: -99999px; overflow: hidden; 
background-repeat: no-repeat; }
+.ui-icon-circle-plus { background-position: 0 -192px; }
+.ui-icon-circle-minus { background-position: -16px -192px; }
+.ui-icon-closethick { background-position: -96px -128px; }             
+.ui-icon { width: 16px; height: 16px; background-image: url(ui-icons.png); }
+
+.mp-button { margin-top: 8px; cursor:pointer; text-decoration: none; padding: 
3px; }
+.mp-button a { color: #ffffff; }
+.mp-button a:visited { color: #ffffff; }
+.mp-button a:hover { color: #ffffff; }
+.mp-button a:focus { color: #ffffff; }
+.mp-button a:active { color: #ffffff; }
+.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; }
+.ui-state-default, .ui-widget-content .ui-state-default { border: 1px solid 
#77d5f7; background: #0078ae; font-weight: normal; color: #ffffff; outline: 
none; }
+.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { 
color: #ffffff; text-decoration: none; outline: none; }
+.ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd; color: 
#222222; }
+
+
+.MagmaMapEdit { width: 88%; height: 500px; float: left; }
+.MagmaMapListContainer { width: 10%; float: right; height: 500px; border: 1px 
solid gray; overflow: scroll }
+.actioncell { display: none }
+.element-hover .actioncell {display: auto}
+.button { background: url('icons.png'); width: 32px; height: 32px }
+.btn-view { background-position: 0 32px }
+.btn-point { background-position: -128px 32px }
+.btn-line { background-position: -32px 32px }
+.btn-poly { background-position: -64px 32px }
+.btn-route { background-position: -96px 32px }
+
+.btn-view.selected { background-position: 0 0px }
+.btn-point.selected { background-position: -128px 0px }
+.btn-line.selected { background-position: -32px 0px }
+.btn-poly.selected { background-position: -64px 0px }
+.btn-route.selected { background-position: -96px 0px }

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.html
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.html?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.html
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.html
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1,19 @@
+<html>
+       <head>
+               <script type="text/javascript" 
src="http://maps.google.com/maps?file=api&v=2&sensor=false";></script>
+               <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js";></script>
+               <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js";></script>
+               <script type="text/javascript" src="mapDisplay.js"></script>
+               <script type="text/javascript" src="mapEditor.js"></script>
+               <link href="mapEditor.css" rel="stylesheet"/>
+       </head>
+       <body>
+               <input type="text" id="content" style="width: 100%" 
value="route;0!41.76106872528615,12.974853515625;41.97786911170172,13.04351806640625;41.98195261665715,13.70269775390625;42.20207291264876,13.84002685546875;42.20207291264876,14.095458984375;>line;1!41.62776153144344,13.1781005859375;41.76516610331408,13.24127197265625;41.7672146942102,13.5845947265625;41.80203073088394,13.6285400390625;41.812267143599804,13.75213623046875;41.85728792769134,13.75762939453125;41.85524221544658,13.86199951171875!{add:
 'ciao'}>"/>
+               <div id="map"></div>
+               <div id="maplistcontainer">
+                       <table id="maplist"></table>
+               </div>
+               <script>new MapEditor('map','maplist', 'content')</script>
+       </body>
+
+</html>
\ No newline at end of file

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js?rev=891652&view=auto
==============================================================================
--- 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js
 (added)
+++ 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapEditor.js
 Thu Dec 17 11:30:41 2009
@@ -0,0 +1,701 @@
+
+MapEditor = function(id, listid, fieldid, options) {
+         this.map = null;
+         this.dom = {
+           mapDiv: $("#" + id),
+           markerDivs: [],
+           list: $("#" + listid),
+           field: document.getElementById(fieldid)
+         }
+         if (!options) {
+                 this.options = {
+                                 markers: true,
+                                 polylines : true,
+                                 polygons: true,
+                                 routes: true,
+                                 center: "0,0",
+                                 autocenter: true,
+                                 defaultcontrols: true,
+                                 zoom: 2
+                 };
+         } else {
+                 this.options = options;
+         }
+         this.geometries = {};
+         this.shared_bounds = null;
+         this.counters = { line:0, poly: 0, point: 0, route: 0};
+         
+         this.editingNow = false;
+         this.mode = '';
+         
+         if (this.dom.field) this.parseGeometries(this.dom.field.value);
+         
+         this.createMap();
+};
+
+MapEditor.prototype = new MagMap();
+MapEditor.superclass = MagMap.prototype;
+
+MapEditor.prototype.createMap = function() {
+       MapEditor.superclass.createMap.call(this);
+       var me = this;
+       GEvent.addListener(this.map, 'click', function(overlay, latlng) {
+               if (me.editingNow) {
+                       log("editing now: " + me.editingNow);
+                       return;
+               }
+               if (overlay) {
+                       log("clicked on overlay");
+                       return;
+               }
+               // Editing mode
+               if (!me.mode) {
+                       return;
+               }
+               var new_geometry = new Geometry();
+               new_geometry.create(me.mode, [{lat: latlng.lat(), lng: 
latlng.lng()}]);
+               new_geometry.newIndex(me);
+               me.addGeometry(new_geometry);
+               me.map.addOverlay(new_geometry.overlay);
+               new_geometry.startEditing();
+               if (me.mode != 'point') me.editingNow = true;
+       });
+       me.addEditingUI();
+}
+
+MapEditor.prototype.addGeometry = function(geometry) {
+       MapEditor.superclass.addGeometry.call(this, geometry);
+
+       if (this.counters[geometry.type] < geometry.progressive) 
this.counters[geometry.type] = geometry.progressive + 1;
+       geometry.color = MagMap.getColor(geometry.progressive);
+       
+       geometry.createOverlay();
+       
+       var me = this;
+       if (this.dom.list) {
+               row = document.createElement("tr");
+               geometry.listrow = row;
+               row.geometry = geometry;
+               var colorCell = document.createElement("td");
+               row.appendChild(colorCell);
+               colorCell.style.backgroundColor = geometry.color;
+               colorCell.style.width = "1em";
+               var nameCell = document.createElement("td");
+               row.appendChild(nameCell);
+               nameCell.innerHTML = geometry.type + " " + 
(geometry.progressive + 1);
+               var actionCell = document.createElement("td");
+               actionCell.class="actioncell";
+               row.appendChild(actionCell);
+               var closelink = $('<a href="#" class="ui-icon 
ui-icon-closethick"></a>');
+               closelink[0].geometry = geometry;
+               closelink.click(function () {
+                       GEvent.trigger(this.geometry, 'delete');
+               });
+       
+               actionCell.appendChild(closelink[0]);
+               
+               this.dom.list.append(row);
+               
+               $(row).mouseover(function() {
+                       if (me.hilightTimer) clearTimeout(me.hilightTimer);
+                       var geo = this.geometry;
+                       me.hilightTimer = setTimeout(function() { 
+                               me.selected_geometry = geo;
+                               me.updateHighlightPoly();                       
+                       }, 500);
+                       $(this).addClass("element-hover");
+               });
+               $(row).mouseout(function() {
+                       if (me.hilightTimer) clearTimeout(me.hilightTimer);
+                       me.clearHighlightPoly();
+                       $(this).removeClass("element-hover");
+               });
+       }
+       
+       GEvent.addListener(geometry, 'datasave', function() {
+               geometry.updateCoords();
+               me.saveData();
+       });
+       
+       GEvent.addListener(geometry, 'delete', function() {
+           me.map.removeOverlay(geometry.overlay);
+           delete me.geometries[geometry.key];
+           geometry.listrow.parentNode.removeChild(geometry.listrow);
+               if (me.hilightTimer) clearTimeout(me.hilightTimer);
+               me.clearHighlightPoly();
+           me.saveData();              
+       });
+       
+         if (geometry.overlay instanceof GMarker) {
+           GEvent.addListener(geometry.overlay, 'dragend', function() {
+             GEvent.trigger(geometry, 'datasave');
+           });
+         } else {
+           GEvent.addListener(geometry.overlay, 'endline', function() {
+             me.editingNow = false;
+             log("endline");
+             GEvent.trigger(geometry, 'datasave');
+           });
+           GEvent.addListener(geometry.overlay, 'lineupdated', function() {
+             if (me.mode == 'line' || me.mode == 'poly') {
+               me.statusControl.setText('Click on the final point to finish 
the line.');
+             }
+             GEvent.trigger(geometry, 'datasave');
+           });
+         }
+         GEvent.addListener(geometry.overlay, "click", function(latlng, index) 
{
+                 if (typeof index == "number") {
+                         geometry.overlay.deleteVertex(index);
+                 } 
+                 // TODO hook route waypoints here
+         });     
+
+               if (geometry.type == 'point') {
+                       geometry.overlay.enableDragging();
+               } else if (geometry.type == 'line' || geometry.type == 'poly' 
|| geometry.type == 'route') {
+                       GEvent.addListener(geometry.overlay, 'mouseover', 
function() {
+                               geometry.overlay.enableEditing();
+                       });
+                       GEvent.addListener(geometry.overlay, 'mouseout', 
function() {
+                               geometry.overlay.disableEditing();
+                       });
+               }
+         
+}
+
+
+
+MapEditor.prototype.saveData = function() {
+       var me = this;
+       if (!me.dom.field) return;
+       var tos = "";
+       var geom_name;
+       for (geom_name in me.geometries) {
+               var geometry = me.geometries[geom_name];
+               tos += geometry.serialize();
+       }
+       me.dom.field.value = tos;
+};
+
+
+MapEditor.prototype.clearHighlightPoly = function() {
+         var me = this;
+         if (me.highlightPoly) { me.map.removeOverlay(me.highlightPoly); }     
+}
+
+MapEditor.prototype.updateHighlightPoly = function() {
+         var me = this;
+         this.clearHighlightPoly();
+         if (!me.selected_geometry) { return; }
+         var mapNormalProj = G_NORMAL_MAP.getProjection();
+         var mapZoom = me.map.getZoom();
+         if (me.selected_geometry.type == 'point') {
+           var latlng = me.selected_geometry.overlay.getLatLng();
+           var circle_radius = 20;
+         } else {
+           //if (me.selected_geometry_.isEditable) return;
+           var bounds = me.selected_geometry.overlay.getBounds();
+           if (!bounds) return;
+           var latlng = bounds.getCenter();
+           var southwest_pixel = 
mapNormalProj.fromLatLngToPixel(bounds.getSouthWest(), mapZoom);
+           var northeast_pixel = 
mapNormalProj.fromLatLngToPixel(bounds.getNorthEast(), mapZoom);
+           var circle_radius = Math.floor(Math.abs(southwest_pixel.x - 
northeast_pixel.x)*.7);
+         }
+
+         var latlngs = [];
+         var center_pixel = mapNormalProj.fromLatLngToPixel(latlng, mapZoom);
+         for (var a = 0; a<(21); a++) {
+           var aRad = 18*a*(Math.PI/180);
+           var pixelX = center_pixel.x + circle_radius * Math.cos(aRad);
+           var pixelY = center_pixel.y + circle_radius * Math.sin(aRad);
+           var polyPixel = new GPoint(pixelX, pixelY);
+           var polyPoint = mapNormalProj.fromPixelToLatLng(polyPixel, mapZoom);
+           latlngs.push(polyPoint);
+         }
+         var color = '#FF0000';
+         me.highlightPoly = new GPolygon(latlngs, color, 1, 0.2, color, 0.2, 
{clickable: false});
+         me.map.addOverlay(me.highlightPoly);
+
+         if (bounds) {
+               var tgtzoom = me.map.getBoundsZoomLevel(bounds) - 1;
+               if (Math.abs(tgtzoom - me.map.getZoom()) > 2)
+                       me.map.setZoom(tgtzoom);                  
+         }
+         if (latlng) {
+               me.map.panTo(latlng);
+         }
+         
+       }
+
+
+MapEditor.prototype.addEditingUI = function() {
+         var me = this;
+         
+         if (this.statusControl) {
+           this.map.removeControl(this.statusControl);
+         }
+         this.editControl = new EditControl();
+         this.editControl.magOptions = me.options; 
+         this.map.addControl(this.editControl);
+         this.statusControl = new StatusControl();
+         this.map.addControl(this.statusControl);
+         edit_control = this.editControl;
+         status_control = this.statusControl;
+         this.map.enableGoogleBar();
+
+         GEvent.addListener(edit_control, 'view', function() {
+           me.mode = 'view';
+           me.editingNow = false;
+           status_control.setText('Select geometries by clicking on them.');
+         });
+         GEvent.addListener(edit_control, 'point', function() {
+           me.mode = 'point';
+           me.editingNow = false;
+           status_control.setText('Click on the map to create a new marker.');
+         });
+         GEvent.addListener(edit_control, 'line', function() {
+           me.mode = 'line';
+           me.editingNow = false;
+           status_control.setText('Click on the map to start creating a new 
line.');
+         });
+         GEvent.addListener(edit_control, 'route', function() {
+                   me.mode = 'route';
+                   me.editingNow = false;
+                   status_control.setText('Click on the map to start creating 
a new route line.');
+                 });
+         GEvent.addListener(edit_control, 'poly', function() {
+           me.mode = 'poly';
+           me.editingNow = false;
+           status_control.setText('Click on the map to start creating a new 
filled poly.');
+         });
+}
+
+
+
+var COLORS = [["blue", "#000080"], ["green","#008000"],
+              ["red", "#ff0000"], ["purple", "#800080"]];
+
+MagMap.getColor = function(num) {
+       return COLORS[num % COLORS.length][1];
+}
+
+Geometry.prototype.newIndex = function(magMap) {
+       var index = magMap.counters[this.type]++;
+       this.progressive = index;
+       this.color = MagMap.getColor(index);    
+}
+
+Geometry.prototype.startEditing = function() {
+       if (this.type == 'line' || this.type == 'poly' || this.type == 'route') 
{
+               this.overlay.enableDrawing();
+               this.isEditing = true;
+       } else { 
+               GEvent.trigger(this, 'datasave');
+       }       
+}
+
+Geometry.prototype.updateCoords = function() {
+       if (this.type == 'point') {
+               this.coordinates = [{lat: this.overlay.getLatLng().lat(), lng:  
this.overlay.getLatLng().lng()}];
+       } else if (this.type == 'line' || this.type == 'poly') {
+               this.coordinates = [];
+               for (var i = 0; i < this.overlay.getVertexCount(); i++) {
+                       this.coordinates.push({lat: 
this.overlay.getVertex(i).lat(), lng: this.overlay.getVertex(i).lng()});
+               }
+       } 
+}
+
+Geometry.prototype.getMarkerProperties = function() {
+       return {draggable: true};
+}
+
+Geometry.prototype.parsePreambol = function(spec) {
+       var parts = spec.split(";");
+       this.type = parts[0];
+       this.progressive = parseInt(parts[1]);
+}
+
+Geometry.prototype.serialize = function() {
+       return this.serializePreambol() + "!" + this.serializeCoordinates() + 
"!" + this.serializeAdditional() + ">";
+}
+
+Geometry.prototype.serializePreambol = function() {
+       return this.type + ";" + this.progressive;
+}
+
+Geometry.prototype.serializeCoordinates = function() {
+       var ret = "";
+       for (var i = 0; i < this.coordinates.length; i++) {
+               ret += (Math.round(this.coordinates[i].lat * 1e5) / 1e5) + "," 
+ (Math.round(this.coordinates[i].lng * 1e5) / 1e5) + ";";
+       }       
+       return ret;
+}
+
+Geometry.prototype.serializeAdditional = function() {
+       if (this.type == 'route') {
+               var calcovl = this.overlay.delegateOverlay;
+               for (var name in calcovl) {
+                       var sub = calcovl[name];
+                       if (sub && sub != null && sub['id'] != null && 
sub['levels'] != null && sub['numLevels'] != null && sub['points'] != null) {
+                               return "{zoomFactor: " + sub['zoomFactor'] + ", 
numLevels: " + sub['numLevels'] + ", levels:'" + 
sub['levels'].replace(/\\/g,"\\\\") + "', points:'" + 
sub['points'].replace(/\\/g,"\\\\") + "'}";
+                       }
+               }
+       }
+       return "";
+}
+
+DirectionsPolyline.prototype.getMarkerIcon = function() {
+       if (!this.editMarkerIcon) {
+               var gi = new GIcon();
+               gi.image = "flat-mark.png";
+               gi.iconSize = new GSize(10,10);
+               gi.iconAnchor = new GPoint(5,5);
+               gi.maxHeight = 0;
+               this.editMarkerIcon = gi;
+       }
+       return this.editMarkerIcon;
+}
+
+DirectionsPolyline.prototype.superLoaded = DirectionsPolyline.prototype.loaded;
+
+DirectionsPolyline.prototype.loaded = function() {
+       this.superLoaded();
+       if (!this.drawListener) this.setupListeners();
+}
+
+DirectionsPolyline.prototype.findNearestVertex = function(latlng) {
+       var me = this;
+    var distance = 50000;
+       var index = -1;
+       var tot = me.delegateOverlay.getVertexCount();
+       for (var i = 0; i < tot; i++) {
+               var vertex = me.delegateOverlay.getVertex(i);
+               var acdist = vertex.distanceFrom(latlng);
+               if (acdist < distance) {
+                       index = i;
+                       distance = acdist;
+               }
+       }
+       return index;
+}
+
+DirectionsPolyline.prototype.calculateInsertionPoint = function(latlng) {
+       var me = this;
+       var index = this.findNearestVertex(latlng);
+       if (index == -1) return;
+       var pos = -1;
+       for (var i = 0; i < me.markers.length; i++) {
+               if (me.markers[i].vertexindex) {
+                       if (me.markers[i].vertexindex > index) {
+                               pos = i;
+                               break;
+                       }
+               } else {
+                       pos = i;
+                       break;
+               }
+       }
+       return pos;     
+}
+
+DirectionsPolyline.prototype.setupListeners = function() {
+       var me = this;
+       GEvent.addListener(this.delegateOverlay, 'mouseover', function() {
+               if (me.motim) clearTimeout(me.motim);
+               GEvent.trigger(me, 'mouseover');
+       });
+       GEvent.addListener(this.delegateOverlay, 'click', function(latlng) {
+               if (me.markers && me.markers.length > 0) {
+                       var pos = me.calculateInsertionPoint(latlng);
+                       if (pos == -1) return;
+                       me.geometry.coordinates.splice(pos,0, {lat: 
latlng.lat(), lng:latlng.lng()});
+                       me.disableEditing();
+                       me.enableEditing();
+                       GEvent.trigger(me, 'lineupdated');
+               } else {
+                       GEvent.trigger(me, 'click', latlng);
+               }
+       });
+       GEvent.addListener(this.delegateOverlay, 'mouseout', function() {
+               if (me.motim) clearTimeout(me.motim);
+               me.motim = setTimeout(function() {
+                       GEvent.trigger(me, 'mouseout');
+               }, 1000);
+       });
+}
+
+DirectionsPolyline.prototype.deleteVertex = function(index) {
+       this.geometry.coordinates.splice(index, 1);
+       if (this.markers && this.markers.length > 0) {
+               var mark = this.markers[index];
+               this.markers.splice(index, 1);
+               this.map.removeOverlay(mark);
+       }
+       this.recalc();
+       GEvent.trigger(this, 'lineupdated');
+}
+
+DirectionsPolyline.prototype.disableEditing = function() {
+       if (this.dragging) return;
+       if (this.markers && this.markers.length > 0) {
+               for (var i = 0; i < this.markers.length; i++) {
+                       this.map.removeOverlay(this.markers[i]);
+               }
+               this.markers = [];
+       }
+       if (this.drawMarks && this.drawMarks.length > 0) {
+               for (var i = 0; i < this.drawMarks.length; i++) {
+                       this.map.removeOverlay(this.drawMarks[i]);
+               }
+               delete this.drawMarks;
+       }
+       if (this.drawListener) {
+               GEvent.removeListener(this.drawListener);
+               delete this.drawListener;
+       }
+       if (this.drawDynaListener) {
+               GEvent.removeListener(this.drawDynaListener);
+               delete this.drawDynaListener;
+       }
+       if (this.editDynaListener) {
+               GEvent.removeListener(this.editDynaListener);
+               delete this.editDynaListener;
+       }
+       if (this.tmpmark) {
+               this.map.removeOverlay(this.tmpmark);
+               delete this.tmpmark;
+       }
+       this.setupListeners();
+       delete this.additionalCoordinates;
+}
+
+DirectionsPolyline.prototype.enableDrawing = function() {
+       var me = this;
+       me.drawMarks = [];      
+       var mark = new GMarker(new GLatLng(me.geometry.coordinates[0].lat, 
me.geometry.coordinates[0].lng), {draggable: false, icon: 
this.getMarkerIcon()});
+       mark.dirpolymark = true;
+       me.drawMarks.push(mark);
+       me.map.addOverlay(mark);
+       this.drawListener = GEvent.addListener(this.map, "click", 
function(overlay, latlng) {
+               if (overlay instanceof GMarker && overlay.dirpolymark) {
+                       me.disableEditing();
+               } else {
+                       if (!latlng) {
+                               latlng = new 
GLatLng(me.additionalCoordinates.lat, me.additionalCoordinates.lng);
+                       }
+                       mark = new GMarker(new GLatLng(latlng.lat(), 
latlng.lng()), {draggable: false, icon: me.getMarkerIcon()});
+                       mark.dirpolymark = true;
+                       me.drawMarks.push(mark);
+                       me.map.addOverlay(mark);
+                       me.geometry.coordinates.push({lat: latlng.lat(), lng: 
latlng.lng()});
+                       me.recalc();
+                       GEvent.trigger(me, 'lineupdated');
+               }
+       });
+       this.drawDynaListener = GEvent.addListener(this.map, "mousemove", 
function(latlng) {
+               me.additionalCoordinates = {lat : latlng.lat(), lng: 
latlng.lng() };
+               if (me.dynamicRedrawTo) clearTimeout(me.dynamicRedrawTo);
+               me.dynamicRedrawTo = setTimeout(function() { me.recalc() }, 
500);               
+       });
+}
+
+DirectionsPolyline.prototype.enableEditing = function() {
+       if (this.markers && this.markers.length > 0) return;
+       this.markers = [];
+       var me = this;
+       for (var i = 0; i < this.geometry.coordinates.length; i++) {
+               var mark = new GMarker(new 
GLatLng(this.geometry.coordinates[i].lat, this.geometry.coordinates[i].lng), 
{draggable: true, dragCrossMove:false, icon: this.getMarkerIcon() });
+               this.map.addOverlay(mark);
+               this.markers.push(mark);
+               var coords = this.geometry.coordinates[i];
+               mark.coordindex = i;
+               var route = this.directions.getRoute(i);
+               if (route) {
+                       var step = route.getStep(0);
+                       mark.vertexindex = step.getPolylineIndex() + 1;
+               }
+               this.addEditMarkerListeners(mark);
+       }       
+}
+
+DirectionsPolyline.prototype.addEditMarkerListeners = function(mark) {
+       var me = this;
+       GEvent.addListener(mark, 'mouseover', function() {
+               if (me.motim) clearTimeout(me.motim);
+       });
+       GEvent.addListener(mark, 'mouseout', function() {
+               if (me.motim) clearTimeout(me.motim);
+               me.motim = setTimeout(function() {
+                       GEvent.trigger(me, 'mouseout');
+               }, 1000);
+       });
+       
+       GEvent.addListener(mark, 'drag', function(latlng) {
+               me.dragging = true;
+               me.geometry.coordinates[this.coordindex] = {lat : latlng.lat(), 
lng: latlng.lng() };
+               if (me.dynamicRedrawTo) clearTimeout(me.dynamicRedrawTo);
+               me.dynamicRedrawTo = setTimeout(function() { me.recalc() }, 
500);
+       });
+       GEvent.addListener(mark, 'click', function() {
+               GEvent.trigger(me, 'click', null, this.coordindex);
+       });
+       GEvent.addListener(mark, 'dragend', function(latlng) {
+               me.dragging = false;
+               me.geometry.coordinates[this.coordindex] = {lat : latlng.lat(), 
lng: latlng.lng() }; 
+               me.recalc();
+               GEvent.trigger(me, 'lineupdated');
+       });     
+}
+
+DirectionsPolyline.prototype.recalc = function() {
+       var coords = this.geometry.coordsAsStringArray();
+       if (this.additionalCoordinates) {
+               coords.push(this.additionalCoordinates.lat + "," + 
this.additionalCoordinates.lng);
+       }
+       this.directions.loadFromWaypoints(coords, {getPolyline: true}); 
+}
+
+DirectionsPolyline.prototype.getVertexCount = function() {
+       return this.geometry.coordinates.length;
+}
+
+DirectionsPolyline.prototype.getVertex = function(index) {
+       return new GLatLng(this.geometry.coordinates[index].lat, 
this.geometry.coordinates[index].lng); 
+}
+
+DirectionsPolyline.prototype.insertVertex = function(index, latlon) {
+       this.geometry.coordinates.splice(index,0, {lat: latlon.lat(), lng: 
latlong.lng()});
+}
+
+DirectionsPolyline.prototype.setStrokeStyle = function(style) {
+       
+}
+
+
+
+/* ----------- Edit control, display buttons for shape editing --------------- 
*/
+function EditControl() {
+}
+
+EditControl.prototype = new GControl();
+
+EditControl.prototype.initialize = function(map) {
+  var me = this;
+  me.buttons_ = [];
+ 
+  var control_div = document.createElement('div'); 
+  var control_table = document.createElement('table');
+  var control_tr = document.createElement('tr');
+  
+  var vc_opts = {cssclass: 'btn-view',
+                 name: 'view', tooltip: 'Select geometries by clicking on 
them.'};
+  var view_button = this.createButton(vc_opts);
+  var view_td = document.createElement('td');
+  view_td.appendChild(view_button.img);
+  control_tr.appendChild(view_td);
+
+  if (this.magOptions.markers) {
+         var mc_opts = {cssclass: 'btn-point',
+                        name: 'point', tooltip: 'Click on the map to create a 
new marker.'};
+         var marker_button = this.createButton(mc_opts);
+         var marker_td = document.createElement('td');
+         marker_td.appendChild(marker_button.img);
+         control_tr.appendChild(marker_td);
+  }
+
+  if (this.magOptions.polylines) {
+         var lc_opts = {cssclass: 'btn-line',
+                        name: 'line', tooltip: 'Click on the map to start 
creating a new line.'};
+         var line_button = this.createButton(lc_opts);
+         var line_td = document.createElement('td');
+         line_td.appendChild(line_button.img);
+         control_tr.appendChild(line_td);
+  }
+  
+  if (this.magOptions.routes) {
+         var lc_opts = {cssclass: 'btn-route',
+                 name: 'route', tooltip: 'Click on the map to start creating a 
new route.'};
+         var route_button = this.createButton(lc_opts);
+         var route_td = document.createElement('td');
+         route_td.appendChild(route_button.img);
+         control_tr.appendChild(route_td);
+  }
+         
+  if (this.magOptions.polygons) {
+         var pc_opts = {cssclass: 'btn-poly',
+                        name: 'poly', tooltip: 'Click on the map to start 
creating a new filled poly.'};
+         var poly_button = this.createButton(pc_opts);
+         var poly_td = document.createElement('td');
+         poly_td.appendChild(poly_button.img);
+         control_tr.appendChild(poly_td);
+  }  
+  
+  control_table.appendChild(control_tr);
+  control_div.appendChild(control_table);
+  GEvent.trigger(view_button.img, 'click');
+  map.getContainer().appendChild(control_div);
+  return control_div;
+} 
+ 
+EditControl.prototype.createButton = function(button_opts) {
+  var me = this;
+  var button = {};
+  button.opts = button_opts;
+
+  var button_img = document.createElement('div');
+  button_img.style.cursor = 'pointer';
+  button_img.width = '32';
+  button_img.height = '32';
+  button_img.border = '0';
+  $(button_img).addClass('button').addClass(button_opts.cssclass);
+  button_img.id = button_opts.name+'_control';
+  GEvent.addDomListener(button_img, "click", function() { 
+    for (var i = 0; i < me.buttons_.length; i++) {
+      $(me.buttons_[i].img).removeClass('selected');
+    }
+    $(button_img).addClass('selected');
+    GEvent.trigger(me, button_opts.name);
+  });  
+
+  button.img = button_img;
+  me.buttons_.push(button);
+  return button;
+}
+
+EditControl.prototype.getDefaultPosition = function() {
+  return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(306, 0));
+}
+
+
+
+
+/* ----------- Status control, to display statud informations ---------------- 
*/
+function StatusControl() {
+}
+
+StatusControl.prototype = new GControl();
+
+StatusControl.prototype.initialize = function(map) {
+  var me = this;
+  var status_div = document.createElement('span');
+  status_div.style.color = 'grey';
+  status_div.style.backgroundColor = 'white';
+  status_div.style.border = '1px solid grey';
+  status_div.style.padding = '5px';
+  status_div.style.fontSize = '11px';
+  status_div.innerHTML = 'Select geometries by clicking on them.';
+  this.status_div = status_div;
+  map.getContainer().appendChild(status_div);
+  return this.status_div;
+}
+
+StatusControl.prototype.setText = function(text) {
+  this.status_div.innerHTML = text;
+}
+
+StatusControl.prototype.getDefaultPosition = function() {
+  return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(492, 5));
+}
+
+function log(string) {
+}

Added: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/ui-icons.png
URL: 
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/ui-icons.png?rev=891652&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/ui-icons.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to