Author: simoneg
Date: Fri Dec 18 05:15:13 2009
New Revision: 892140
URL: http://svn.apache.org/viewvc?rev=892140&view=rev
Log:
LABS-503 : Mappable smart lists
Added:
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MakeSmartListMapped.aj
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedListStyle.java
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedSmartListProducer.java
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/tableToMap.js
Modified:
labs/magma/trunk/beans-map/src/main/java/org/apache/magma/beans/MagMapBean.java
labs/magma/trunk/website-maps-google/pom.xml
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/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
Modified:
labs/magma/trunk/beans-map/src/main/java/org/apache/magma/beans/MagMapBean.java
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/beans-map/src/main/java/org/apache/magma/beans/MagMapBean.java?rev=892140&r1=892139&r2=892140&view=diff
==============================================================================
---
labs/magma/trunk/beans-map/src/main/java/org/apache/magma/beans/MagMapBean.java
(original)
+++
labs/magma/trunk/beans-map/src/main/java/org/apache/magma/beans/MagMapBean.java
Fri Dec 18 05:15:13 2009
@@ -53,6 +53,9 @@
private List<MapShape> shapes = null;
+ private String identifier;
+
+
public String getValue() {
if (this.modified) serialize();
return value;
@@ -110,14 +113,24 @@
return ret;
}
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+
@Override
public int hashCode() {
return new HashCodeBuilder(51, 15)
.append(this.center)
.append(this.ppm)
.append(this.getValue())
+ .append(this.identifier)
.toHashCode();
}
-
+
}
Modified: labs/magma/trunk/website-maps-google/pom.xml
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/pom.xml?rev=892140&r1=892139&r2=892140&view=diff
==============================================================================
--- labs/magma/trunk/website-maps-google/pom.xml (original)
+++ labs/magma/trunk/website-maps-google/pom.xml Fri Dec 18 05:15:13 2009
@@ -26,5 +26,10 @@
<artifactId>website-jquery</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>website-beansview</artifactId>
+ <version>0.0.3-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified:
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=892140&r1=892139&r2=892140&view=diff
==============================================================================
---
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
(original)
+++
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/htmlpieces/MapBeanHtmlOutputPiece.java
Fri Dec 18 05:15:13 2009
@@ -26,7 +26,8 @@
String val = "map" + value.hashCode();
val = val.replace('-', '_');
String md = value.getValue();
- head.addRawScript("init-" + val, "function init" + val + "() {
new MagMap().init('" + val + "','" + StringEscapeUtils.escapeJavaScript(md) +
"'); }");
+ if (md == null) md = "";
+ head.addRawScript("init-" + val, "var " + val + "=null;
function init" + val + "() { var mm = new MagMap();mm.init('" + val + "','" +
StringEscapeUtils.escapeJavaScript(md) + "');" + val + "=mm; }");
head.addDoOnload("init" + val);
}
Added:
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MakeSmartListMapped.aj
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MakeSmartListMapped.aj?rev=892140&view=auto
==============================================================================
---
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MakeSmartListMapped.aj
(added)
+++
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MakeSmartListMapped.aj
Fri Dec 18 05:15:13 2009
@@ -0,0 +1,36 @@
+package org.apache.magma.website.maps;
+
+import org.apache.magma.website.maps.MappedSmartListProducer;
+import org.apache.magma.website.beansview.SmartList;
+import org.apache.magma.website.beansview.SmartListProducer;
+
+public aspect MakeSmartListMapped {
+
+ private String[] SmartList.mappedFields = null;
+
+ public String[] SmartList.getMappedFields() {
+ return this.mappedFields;
+ }
+
+ public SmartList SmartList.setMappedFields(String... fields) {
+ this.mappedFields = fields;
+ return this;
+ }
+
+ public boolean SmartList.isMapped() {
+ return this.mappedFields != null && this.mappedFields.length >
0;
+ }
+
+
+ SmartListProducer around(SmartList list, Class clzz) :
+ call(SmartListProducer.new(..))
+ && this(list)
+ && args(clzz) {
+ if (list.isMapped()) {
+ return new MappedSmartListProducer(clzz,
list.getMappedFields());
+ } else {
+ return proceed(list, clzz);
+ }
+ }
+
+}
Added:
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedListStyle.java
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedListStyle.java?rev=892140&view=auto
==============================================================================
---
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedListStyle.java
(added)
+++
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedListStyle.java
Fri Dec 18 05:15:13 2009
@@ -0,0 +1,24 @@
+package org.apache.magma.website.maps;
+
+import org.apache.magma.basics.LocalizableString;
+import org.apache.magma.website.beansview.ListStyleTable;
+
+public class MappedListStyle extends ListStyleTable {
+
+ @Override
+ protected void closeHeaderRow() {
+ buff.append("<th class=\"MagmaList-HeaderCell
MagmaMappedShapes\">");
+ buff.append(new LocalizableString("Coordinates").toString());
+ buff.append("</th>");
+ super.closeHeaderRow();
+ }
+
+ @Override
+ protected void closeRow() {
+ buff.append("<td class=\"MagmaList-Cell MagmaMappedShapes\">");
+ buff.append("${list.shapesFor($row)}");
+ buff.append("</td>");
+ super.closeRow();
+ }
+
+}
Added:
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedSmartListProducer.java
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedSmartListProducer.java?rev=892140&view=auto
==============================================================================
---
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedSmartListProducer.java
(added)
+++
labs/magma/trunk/website-maps-google/src/main/java/org/apache/magma/website/maps/MappedSmartListProducer.java
Fri Dec 18 05:15:13 2009
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+package org.apache.magma.website.maps;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.magma.basics.MagmaException;
+import org.apache.magma.beans.BeanHandler;
+import org.apache.magma.beans.MagMapBean;
+import org.apache.magma.beans.MagmaBeanSupport;
+import org.apache.magma.website.Head;
+import org.apache.magma.website.beansview.SmartListProducer;
+import org.apache.magma.website.htmlpieces.HtmlOutputPiece;
+import org.apache.magma.website.htmlpieces.HtmlPieces;
+
+public class MappedSmartListProducer extends SmartListProducer {
+
+ private String[] fields;
+ private MagMapBean mapBean;
+ private HtmlOutputPiece<MagMapBean> outputPiece;
+
+
+ public <T extends MagmaBeanSupport> MappedSmartListProducer(Class<T>
myclass, String... fields) {
+ super(myclass);
+ mapBean = new MagMapBean();
+ mapBean.setIdentifier(this.getCompletePath() + "-map");
+ outputPiece = HtmlPieces.outputFor(MagMapBean.class);
+ this.fields = fields;
+ }
+
+
+ @Override
+ public void head(Head head) {
+ outputPiece.head(mapBean, head);
+ head.addExternalScript("magma:/common/maps/tableToMap.js");
+ head.addDoOnload("TableMap_mappize");
+ super.head(head);
+ }
+
+ @Override
+ public void produce(Writer stream) throws IOException {
+ // We cannot use non-table cause javascript depends on data
inside the table
+ // we could solve this with HTML5 microtype informations
+ this.listStyle = new MappedListStyle();
+ stream.write("<div class=\"MagmaMappedList\">");
+ super.produce(stream);
+ stream.write(outputPiece.output(mapBean));
+ stream.write("</div>");
+ }
+
+ public String shapesFor(MagmaBeanSupport bean) {
+ BeanHandler handler = bean.handler();
+ StringBuilder ret = new StringBuilder();
+ for (String fld : this.fields) {
+ Object valueobj = handler.getValue(fld);
+ if (valueobj == null) continue;
+ if (!(valueobj instanceof MagMapBean)) throw new
MagmaException("Property {0}.{1} is not a map field, it is of type {2}
instead", bean.getClass(), fld, valueobj.getClass());
+ MagMapBean magmap = (MagMapBean) valueobj;
+ ret.append(magmap.getValue());
+ }
+ return ret.toString();
+ }
+
+}
Modified:
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=892140&r1=892139&r2=892140&view=diff
==============================================================================
---
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.css
(original)
+++
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.css
Fri Dec 18 05:15:13 2009
@@ -1 +1,2 @@
-.MagmaMap { width: 100%; height: 300px }
\ No newline at end of file
+.MagmaMap { width: 100%; height: 300px }
+.tooltip { border: 1px solid black; background: white }
\ No newline at end of file
Modified:
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=892140&r1=892139&r2=892140&view=diff
==============================================================================
---
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.html
(original)
+++
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.html
Fri Dec 18 05:15:13 2009
@@ -9,7 +9,7 @@
</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="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;!{link:
"http://www.google.com", 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>
Modified:
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=892140&r1=892139&r2=892140&view=diff
==============================================================================
---
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js
(original)
+++
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/mapDisplay.js
Fri Dec 18 05:15:13 2009
@@ -35,8 +35,6 @@
MagMap.prototype.createMap = function() {
var me = this;
-
-
this.map = new GMap2(this.dom.mapDiv[0],
{googleBarOptions:
{ showOnLoad: true, resultList:
G_GOOGLEBAR_RESULT_LIST_SUPPRESS,
@@ -49,37 +47,33 @@
}
);
- 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());
- }
- }
+ GEvent.addListener(this.map, "mousemove", function(latlng) {
+ me.map.lastCoords = latlng;
+ });
+
+ var map = this.map;
+ map.mm_tooltip = $('<div class="tooltip"></div>')[0];
+ this.dom.mapDiv[0].appendChild(map.mm_tooltip);
+ map.mm_showTooltip = function(text, latlng) {
+ $(map.mm_tooltip).text(text);
+ if (!latlng) latlng = map.lastCoords;
+ var
point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
+ var
offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(latlng,map.getZoom());
+ var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new
GSize(offset.x - point.x,- offset.y + point.y ));
+ pos.apply(map.mm_tooltip);
+ $(map.mm_tooltip).toggle(true);
}
- 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);
+ map.mm_hideTooltip = function(text, latlng) {
+ $(map.mm_tooltip).toggle(false);
}
+
+ for (var geomkey in this.geometries) {
+ var geom = this.geometries[geomkey];
+ this.addGeometryOverlay(geom);
+ }
+
+ this.recenter();
+
if (this.options.defaultcontrols) {
this.map.addControl(new GLargeMapControl());
this.map.addControl(new GMapTypeControl());
@@ -98,6 +92,71 @@
};
+MagMap.prototype.recenter = function() {
+ if (this.options.autocenter) {
+ 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 instanceof GMarker) {
+ mapbounds.extend(ovl.getLatLng())
+ } else {
+ var geombounds = ovl.getBounds();
+ if (geombounds != null) {
+
mapbounds.extend(geombounds.getSouthWest());
+
mapbounds.extend(geombounds.getNorthEast());
+ }
+ }
+ }
+ if (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);
+ }
+}
+
+MagMap.prototype.addGeometryOverlay = function(geom) {
+ var map = this.map;
+ var ovl = geom.overlay;
+ if (ovl == null) {
+ ovl = geom.createOverlay();
+ }
+ map.addOverlay(ovl);
+ if (geom.description) {
+ GEvent.addListener(ovl,"mouseover", function() {
+ map.mm_showTooltip(geom.description);
+ });
+ GEvent.addListener(ovl,"mouseout", function() {
+ map.mm_hideTooltip();
+ });
+ }
+ if (geom.link) {
+ GEvent.addListener(ovl,"click", function() {
+ document.location = geom.link;
+ });
+ }
+}
+
+MagMap.prototype.parseGeometriesWithOptions = function(geometries, options) {
+ 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]);
+ geom.parseAdditional(options);
+ this.addGeometry(geom);
+ }
+ }
+}
+
MagMap.prototype.parseGeometries = function(geometries) {
var defs = geometries.split('>');
for (var i = 0; i < defs.length; i++) {
@@ -112,7 +171,7 @@
MagMap.prototype.addGeometry = function(geom) {
if (this.map != null) {
- this.map.addOverlay(geom.createOverlay());
+ this.addGeometryOverlay(geom);
}
this.geometries[geom.key] = geom;
}
@@ -133,8 +192,9 @@
this.key = "overlay-" + new Date().getTime() + (Geometry.prog++);
this.parsePreambol(parts[0]);
this.parseCoordinates(parts[1]);
- if (parts.length == 3)
+ if (parts.length >= 3)
this.parseAdditional(parts[2]);
+
}
Geometry.prototype.parsePreambol = function(spec) {
@@ -156,7 +216,10 @@
Geometry.prototype.parseAdditional = function(spec) {
if (spec.length == 0) return;
- var parsed = eval("(" + spec + ")");
+ var parsed = spec;
+ if (typeof spec == "string") {
+ parsed = eval("(" + spec + ")");
+ }
for (var name in parsed) {
if (!this[name])
this[name] = parsed[name];
@@ -176,6 +239,7 @@
Geometry.prototype.createOverlay = function() {
if (this.overlay && this.overlay != null) return this.overlay;
+ var me = this;
var overlay;
if (this.type == 'point') {
overlay = new GMarker(new GLatLng(this.coordinates[0].lat,
this.coordinates[0].lng), this.getMarkerProperties());
@@ -190,8 +254,9 @@
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;
}
@@ -205,10 +270,11 @@
}
Geometry.prototype.getMarkerProperties = function() {
- return {};
+ return { };
}
DirectionsPolyline = function(geometry) {
+ var me = this;
this.geometry = geometry;
this.directions = new GDirections();
this.delegateOverlay = null;
@@ -216,10 +282,21 @@
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});
+ /*
+ // TODO this does not work correctly
+ GEvent.addListener(this.delegateOverlay, 'click',
function(latlng) {
+ GEvent.trigger(me, 'click', latlng);
+ });
+ GEvent.addListener(this.delegateOverlay, 'mouseover',
function() {
+ GEvent.trigger(me, 'mouseover');
+ });
+ GEvent.addListener(this.delegateOverlay, 'mouseout', function()
{
+ GEvent.trigger(me, 'mouseout');
+ });
+ */
} else {
this.directions.loadFromWaypoints(geometry.coordsAsStringArray(), {getPolyline:
true});
}
- var me = this;
GEvent.addListener(this.directions, 'load', function() {
me.loaded();
});
@@ -268,6 +345,18 @@
}
this.delegateOverlay = this.directions.getPolyline();
if (this.map) this.map.addOverlay(this.delegateOverlay);
+ /*
+ // TODO this does not work correctly
+ GEvent.addListener(this.delegateOverlay, 'click', function(latlng) {
+ GEvent.trigger(me, 'click', latlng);
+ });
+ GEvent.addListener(this.delegateOverlay, 'mouseover', function() {
+ GEvent.trigger(me, 'mouseover');
+ });
+ GEvent.addListener(this.delegateOverlay, 'mouseout', function() {
+ GEvent.trigger(me, 'mouseout');
+ });
+ */
}
DirectionsPolyline.prototype.getBounds = function() {
Added:
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/tableToMap.js
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/tableToMap.js?rev=892140&view=auto
==============================================================================
---
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/tableToMap.js
(added)
+++
labs/magma/trunk/website-maps-google/src/main/resources/org/apache/magma/website/maps/tableToMap.js
Fri Dec 18 05:15:13 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+TableMap_hideall = function() {
+ var head = document.getElementsByTagName('head')[0],
+ style = document.createElement('style'),
+ rules = document.createTextNode('div.MagmaMappedList
table.MagmaList { display: none; } ');
+
+ style.type = 'text/css';
+ if(style.styleSheet)
+ style.styleSheet.cssText = rules.nodeValue;
+ else style.appendChild(rules);
+ head.appendChild(style);
+}
+
+TableMap_hideall();
+
+function TableMap_mappize() {
+ $('div.MagmaMappedList').each(function() {
+ goWithMap(this);
+ });
+}
+
+function goWithMap(mytbl) {
+ var mapdiv = $('.MagmaMap', mytbl);
+ var mapid = mapdiv[0].id;
+ var magmap = null;
+ eval("magmap = "+mapid);
+ if (!magmap) return;
+ $('tbody tr', mytbl).each(function() {
+ var shapes = $('td.MagmaMappedShapes', this).text();
+ if (shapes == '') return;
+ var txt = $('td:not(.MagmaMappedShapes)', this).text();
+ try {
+ magmap.parseGeometriesWithOptions(shapes, {description:
txt});
+ } catch (e) {}
+ });
+ magmap.recenter();
+}
+
+var HtmlStrippingRegExp = /<\/?[^>]+>/gi;
+function stripHtml(str){
+ str = str.replace(HtmlStrippingRegExp,"");
+ return str;
+}
+
+function extractLink(ele) {
+ var aele = $('a',ele).get(0);
+ return aele != null ? aele.href : null;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]