[Mapbender-commits] r6270 - in trunk/mapbender: http/javascripts
http/plugins lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jun 15 08:10:51 EDT 2010
Author: kmq
Date: 2010-06-15 12:10:51 +0000 (Tue, 15 Jun 2010)
New Revision: 6270
Modified:
trunk/mapbender/http/javascripts/geometry.js
trunk/mapbender/http/plugins/mb_loadkmlgeorss.js
trunk/mapbender/lib/point.js
Log:
rework the georss display to show more than just points
Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js 2010-06-15 09:46:58 UTC (rev 6269)
+++ trunk/mapbender/http/javascripts/geometry.js 2010-06-15 12:10:51 UTC (rev 6270)
@@ -874,6 +874,9 @@
text += ")";
}
+ else if(this.geomType == geomType.point){
+ text = this.get(0).toText();
+ }
}
return text;
@@ -1284,6 +1287,15 @@
}
}
break;
+ case geomType.point:
+ var point = this.get(0);
+ if(typeof(!point.z)) {
+ return "POINT(" +point.x + " " + point.y + ")";
+ }
+ else {
+ return "POINT Z (" + point.x + " " + point.y + " " + point.z + ")";
+ }
+ break;
}
return text;
};
Modified: trunk/mapbender/http/plugins/mb_loadkmlgeorss.js
===================================================================
--- trunk/mapbender/http/plugins/mb_loadkmlgeorss.js 2010-06-15 09:46:58 UTC (rev 6269)
+++ trunk/mapbender/http/plugins/mb_loadkmlgeorss.js 2010-06-15 12:10:51 UTC (rev 6270)
@@ -75,6 +75,7 @@
var translatedI18nObject = Mapbender.cloneObject(originalI18nObject);
var that = this;
+that.feeds = [];
$('<div id="'+ options.id +'_dialog"><label>GeoRSS <input type="radio" name="type" value="GeoRSS" checked="checked"/></label>'+
'<label>KML<input type="radio" name="type" value="KML"></label><br />'+
@@ -114,76 +115,57 @@
var popup = null;
$("table", $dialog).remove();
var $table = $("<table><thead><tr><th class='labelName'>"+ translatedI18nObject.labelName +"</th></tr></thead><tbody></tbody></table>");
+
if(data.features){
// we always transform _from_ 4326 geoRSS and KML use this as their default
var projSrc = new Proj4js.Proj('EPSG:4326');
var projDest = new Proj4js.Proj($map.epsg);
var markeroptions = {width: "19px", height: "34px"};
- for(var i in data.features){
- title = data.features[i].properties.title || data.features[i].properties.name || translatedI18nObject.labelUntitled;
- $row = $("<tr><td>"+ title +"</td></tr>");
- if(data.features[i].properties.iconurl){
- markeroptions.img = {url: data.features[i].properties.iconurl, offset: {x:0,y:0}} ;
- }
- var x = data.features[i].geometry.coordinates[0];
- var y = data.features[i].geometry.coordinates[1];
- point = Proj4js.transform(projSrc, projDest,new Mapbender.Point(x,y));
- marker = new Mapbender.Marker(point,$map, markeroptions);
- markers.push(marker);
+ var g = null;
+ var map = $('#mapframe1').mapbender();
+ //title = feature.properties.title || feature.properties.name || translatedI18nObject.labelUntitled;
- $row.click((function(feature, marker, markerIndex){
- return function(){
- var x = feature.geometry.coordinates[0];
- var y = feature.geometry.coordinates[1];
-
- var buffer = new Mapbender.Point(options.buffer,options.buffer);
- var a = Proj4js.transform(projSrc,projDest,new Mapbender.Point(x,y));
- a = a.minus(buffer);
+
+ var geomArray = new GeometryArray();
+ geomArray.importGeoJSON(data);
+ var h = new Highlight(['mapframe1'], "mapframe1_" + parseInt(Math.random()*100000,10),{
+ "position":"absolute",
+ "top": "0px",
+ "left": "0px",
+ "z-index": "80" },1);
+ for(var i =0; i < geomArray.count(); i++){
+ g = geomArray.get(i);
- var b = Proj4js.transform(projSrc,projDest,new Mapbender.Point(x,y));
- b = b.plus(buffer);
+ // per feature stuff
+ //g.e.setElement("Mapbender:icon", options.img.url); //? where to get, let the server do it ?
+ //g.e.setElement("Mapbender:iconOffsetX", options.img.offset.x);
+ //g.e.setElement("Mapbender:iconOffsetY", options.img.offset.y);
+ //g.e.setElement("Mapbender:iconZIndex", options.img.offset.y);
- $map.calculateExtent( new Mapbender.Extent(a,b));
- $map.setMapRequest();
-
- var offset = $('#'+options.target).offset();
- var mapPoint = $map.convertRealToPixel(Proj4js.transform(projSrc,projDest, new Mapbender.Point(x,y)));
- marker.remove();
- point = Proj4js.transform(projSrc, projDest, new Mapbender.Point(x,y));
- var markeroptions = {width: "19px", height: "34px", img:{url: "../img/marker/orange.png", offset: new Point(-10,-34)}};
- var highlightmarker = new Mapbender.Marker(point,$map, markeroptions);
-
- $('<div style="max-height:20em; max-width:20em">'+ feature.properties.description + "</div>").dialog({
- title: feature.properties.title || feature.properties.name || translatedI18nObject.labelUntitled,
- position: [mapPoint.x+offset.left+20, mapPoint.y + offset.top+20 ],
- autoOpen: true,
- buttons : {"Close" :function(){
- $(this).dialog("close");
- }},
- close: function(){
- highlightmarker.remove();
- point = Proj4js.transform(projSrc, projDest, new Mapbender.Point(x,y));
- var markeroptions = {width: "19px", height: "34px"};
- if(feature.properties.iconurl){
- markeroptions.img = {url: feature.properties.iconurl, offset: {x:0,y:0}} ;
- }
- marker = new Mapbender.Marker(point,$map, markeroptions);
- markers.push(marker);
- }
- });
- };
- })(data.features[i], marker));
- $row.css("cursor","pointer");
- $("tbody",$table).append($row);
-
-
+ h.add(g);
+
}
+ h.paint();
+ map.events.afterMapRequest.register(function () {
+ h.paint();
+ });
+
+ var index = that.feeds.push({
+ url: url,
+ geomArray: geomArray,
+ highlight: h,
+ });
+ index--; //push returns the length
+
+
+
}
var $tableDialog = $("<div></div>").dialog({
width: "450",
height: "500",
position: options.position,
beforeclose: function(){
+ h.clean();
for(var i in markers){
markers[i].remove();
}
@@ -217,7 +199,6 @@
});
Mapbender.events.localize.register(function(){
Mapbender.modules.i18n.queue(options.id, originalI18nObject, function(translatedI18nObject){
- alert('need to localize here');
$('.labelLoadError').text(translatedI18nObject.labelLoadError);
$('.labelUrlBox').text(translatedI18nObject.labelUrlBox);
})
@@ -227,4 +208,42 @@
$(that).click(function(){
$('#'+options.id+'_dialog').dialog('open');
});
+ $('#mapframe1').click(function(e){
+ var map = $('#mapframe1').mapbender();
+ var pos = map.getMousePosition(e);
+ var clickPoint = map.convertPixelToReal(new Point(pos.x,pos.y));
+ var feed = null;
+ var requestGeometries = [];
+ for (var i in that.feeds){
+ feed = that.feeds[i] ;
+
+ for(var j = 0; j < feed.geomArray.count(); j++){
+ g = feed.geomArray.get(j);
+ requestGeometries.push(g.toText());
+ }
+ var req = new Mapbender.Ajax.Request({
+ url: "../php/intersection.php",
+ method: "intersect",
+ parameters: {
+ clickPoint: clickPoint.toText(),
+ geometries: requestGeometries
+ },
+ callback: function(result, success, message){
+ if(!success){
+ return;
+ }
+ // this is basically an onclick handler, !intersects means
+ // the click didn't happen on the polygon
+ if(!result.geometries){
+ return;
+ }
+ for(var i in geometries){
+ //TODO: add the popup handler
+ }
+
+ }
+ });
+ req.send();
+ }
+ });
});
Modified: trunk/mapbender/lib/point.js
===================================================================
--- trunk/mapbender/lib/point.js 2010-06-15 09:46:58 UTC (rev 6269)
+++ trunk/mapbender/lib/point.js 2010-06-15 12:10:51 UTC (rev 6270)
@@ -131,3 +131,12 @@
return "[" + this.x + ", " + this.y + ", " + this.z + "]";
}
};
+
+Mapbender.Point.prototype.toText = function(){
+ if (typeof(this.z == "undefined")) {
+ return "POINT(" + this.x + " " + this.y + ")";
+ }
+ else {
+ return "POINT Z (" + this.x + " " + this.y + " " + this.z + ")";
+ }
+}
More information about the Mapbender_commits
mailing list