[Mapbender-commits] r9277 - in trunk/mapbender/http/extensions/mobilemap: . _build mod_mapbender
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Aug 18 02:45:49 PDT 2015
Author: armin11
Date: 2015-08-18 02:45:49 -0700 (Tue, 18 Aug 2015)
New Revision: 9277
Modified:
trunk/mapbender/http/extensions/mobilemap/_build/ngms_event.js
trunk/mapbender/http/extensions/mobilemap/_build/ngms_event.min.js
trunk/mapbender/http/extensions/mobilemap/map.php
trunk/mapbender/http/extensions/mobilemap/mod_mapbender/search.js
Log:
Add new get parameter for layerid in mobilemap for better integration in ckan as viewer component!
Modified: trunk/mapbender/http/extensions/mobilemap/_build/ngms_event.js
===================================================================
--- trunk/mapbender/http/extensions/mobilemap/_build/ngms_event.js 2015-08-12 09:12:16 UTC (rev 9276)
+++ trunk/mapbender/http/extensions/mobilemap/_build/ngms_event.js 2015-08-18 09:45:49 UTC (rev 9277)
@@ -713,7 +713,6 @@
*/
-var templayer;
var maxlayers = 5;
var maxresults = 40;
@@ -777,8 +776,10 @@
}
//SP: Reset Feature List
$("#featurelist").empty();
- //
- if(querylayer.length>0) {
+ //SP: DHM Höhe in Ergebnisliste
+ getHeight(lonlat.lon, lonlat.lat, actuallang);
+ // Query Layer
+ if(querylayer.length > 0) {
//SP: alle queryable layers iterieren
for (var i = 0; i < querylayer.length; i++) {
//SP: bei nur einem Feature direkte Referenz, ansonsten array
@@ -798,7 +799,8 @@
+ '&X=' + evt.xy.x + '&Y=' + evt.xy.y
+ '&INFO_FORMAT=text/html'
+ '&FORMAT=image/png' //only for some wms that have problems if this parameter is not given
- + '&STYLES='; //only for some wms that have problems if this parameter is not given
+ + '&STYLES=' //only for some wms that have problems if this parameter is not given
+ + '&FEATURE_COUNT=100';
// Legende für Feature Info
var legendurl = ql.attr('getmapurl')
@@ -832,8 +834,7 @@
// Standardabfrage, falls keiner ausgewählt ist
//d.h. dhm!
var featureurl = 'query/rasterqueryWms.php?coord='+lonlat.lon+ ', '+lonlat.lat+'&lang='+actuallang;
- //alert(featureurl);
- loadFeature(featureurl);
+ loadFeature(featureurl);
}
},
@@ -880,7 +881,40 @@
$('#featurelist').append(feature.html);
refreshFeatureResults();
}
-
+//SP: DHM Höhe abfragen
+function getHeight(lon, lat, lang)
+{
+ var dhm_url = 'query/rasterqueryWms.php?coord=' + lon + ', ' + lat + '&lang=' + lang;
+ $.ajax(
+ {
+ type: 'GET',
+ url: dhm_url,
+ success: function(data)
+ {
+ if (data)
+ {
+ //alert(data);
+ if(data.length < 5)
+ {
+ data = window.lang.convert('Kein Ergebnis!');
+ }
+
+ // Dummy Werte
+ //data = "<html><head></head><body>Höhe: ~204 [m]</body></html>";
+ //data = "Höhe: ~204 [m]";
+
+ // zur Featurelist hinzufügen (Anfang)
+ var html = $('<div>');
+ var collaps = $('<div class="collapsible unselected" data-role="collapsible" data-collapsed="true" data-theme="a" data-content-theme="c" data-inline="true" data-inset="true"></div>');
+ collaps.append('<h3>DHM</h3>');
+ collaps.append(data);
+ html.append(collaps);
+ $('#featurelist').prepend(html);
+ refreshFeatureResults();
+ }
+ }
+ });
+}
//SP: Is feature url valid, call php (PHP Interface über Ajax)
function featureValid(feature)
{
@@ -1276,6 +1310,17 @@
});
}
+// Suche über Layerid
+function searchLayer(layerid){
+ $.mobile.showPageLoadingMsg();
+ $('#search_results').empty();
+ //$.getJSON(layerid, function(data){
+ appendLayer(layerid);//?
+ $.mobile.hidePageLoadingMsg();
+ //});
+}
+
+
// Parst das JSON-Objekt von MapBender in ein Array [services,layers]
function parseMapBenderJson(json){
// Daten generalisieren
@@ -1395,6 +1440,42 @@
}
+// Fügt die Layer in das DOM ein
+function appendLayerData(services,layers){
+ $("#ownlist").empty();
+ var ownlayers = [];
+ for(var i=0; i<services.length; i++){
+ var srv=services[i];
+ // Layer zuordnen
+ for(var j=0; j<layers.length; j++){
+ var layer=layers[j];
+ var serviceid=layer[0];
+ var lyr=layer[1];
+
+ if(serviceid==srv.id){
+ ownlayers.push(OwnLayer(lyr.id,lyr.title,lyr.name,$(lyr).attr('abstract'),srv.title,$(srv).attr('abstract'),lyr.previewURL,lyr.queryable=='1',srv.getMapUrl,lyr.bbox,srv.avail));
+ }
+ }
+ }
+ var layer=ownlayers[0];
+ $('#ownlist').append(layer);
+ addOpenlayer(layer.attr('layerid'),layer.attr('name'),layer.attr('getMapUrl'));
+ if (layer.attr('queryable') == "true") {
+ setQueryable(layer, true);
+ setQueryCheck(layer, true);
+ } else {
+ setQueryable(layer, false);
+ }
+ validateLayers();
+ validateArrows();
+ //zoom to layer extent
+ var extend=layer.attr('bbox').split(',');
+ var crs = 'EPSG:4326';
+ //alert(mapProj);
+ var p1 = new OpenLayers.LonLat(extend[0],extend[1]).transform(crs,mapProj);
+ var p2 = new OpenLayers.LonLat(extend[2],extend[3]).transform(crs,mapProj);
+ map.zoomToExtent(new OpenLayers.Bounds(p1.lon, p1.lat, p2.lon, p2.lat));
+}
// Alle ausgewählten Overlays entfernen
function clearOwnlist(){
var layers=$('#ownlist').find('.layer');
@@ -1441,8 +1522,44 @@
});
}
+// Layer-Daten hinzufügen
+function appendLayer(layerid){
+
+ // Hintergrundkarte auswählen
+ /*for(var i=0; i<json.backGroundLayer.length; i++){
+ var layer=json.backGroundLayer[i];
+ if(layer.active){
+ var layers=$('#baselayers').find('.baselayer')
+ for(var j=0; j<layers.length; j++){
+ if($(layers[j]).attr('layerids')==layer.name){
+ switchVisibility(layers[j]);
+ break;
+ }
+ }
+ }
+ }*/
+ // Parsen der bbox aus wmc
+ //var bbox = json.wmc.bbox;
+ //var crs = json.wmc.crs;
+ // Alle ausgewählten overlays entfernen
+ clearOwnlist();
+ // Layerids für die Abfrage zusammenstellen
+ /*var layerids="";
+ $.each(json.layerList, function(index,layer){
+ layerids=layerids+","+layer.layerId;
+ });
+ layerids=layerids.substr(1,layerids.length);*/
+ // Overlays auswählen
+ $.getJSON(searchUrl+'&resourceIds='+layerid, function(data){
+ // Informationen sammeln und Parsen
+ var datacollection=parseMapBenderJson(data);
+ appendLayerData(datacollection.services,datacollection.layers);
+ $.mobile.hidePageLoadingMsg();
+ });
+}
+
// Hintergrunddaten in Collapsible aufnehmen
function addBaselayers(){
Modified: trunk/mapbender/http/extensions/mobilemap/_build/ngms_event.min.js
===================================================================
--- trunk/mapbender/http/extensions/mobilemap/_build/ngms_event.min.js 2015-08-12 09:12:16 UTC (rev 9276)
+++ trunk/mapbender/http/extensions/mobilemap/_build/ngms_event.min.js 2015-08-18 09:45:49 UTC (rev 9277)
@@ -25,13 +25,14 @@
text:" "}).click(function(){zoomToBbox(k);$.mobile.changePage($("#mappage"),pageTransition)}));o.append("</br><p>"+l+"%</p>");g=$("<td></td>");g.append("<p><b>"+e+"</b></p><p>"+f+"</p>");g.append("<p><b>"+b+"</b></p><p>"+d+"</p>");n.append(o);n.append(g);p.append(n);h.append(p);b=j+"service=wms&version=1.1.1&request=GetLegendGraphic&format=image/png&layer="+c;h.append($("<br><p><b>Legende:</b></p>"));h.append($('<div class="legendcontainer" data-role="content"><img src="'+b+'"></div>'));m.append(h);
return m}
function FeatureResult(a,b,c,d){this.layername=a;this.position=b;this.url=c;this.html=$("<div>",{"data-sort":b});b=$('<div class="collapsible unselected" data-role="collapsible" data-collapsed="true" data-theme="a" data-content-theme="c" data-inline="true" data-inset="true"></div>');b.append("<h3>"+a+"</h3>");b.append($('<div class="legendcontainer" data-role="content"><img src="'+d+'"></div>'));a=$('<a data-role="button" data-icon="arrow-r" data-iconpos="right" target="_blank" href="'+c+'">Info</a>');
-c=$('<div class="ui-grid-a">');d=$('<div class="ui-block-a">');d.append(b);b=$('<div class="ui-block-b">');b.append(a);c.append(d);c.append(b);this.html.append(c)}var templayer,maxlayers=5,maxresults=40,baseinfo=[];searchUrl="mod_mapbender/search_proxy.php?languageCode=de&resultTarget=web&maxResults="+maxresults;
+c=$('<div class="ui-grid-a">');d=$('<div class="ui-block-a">');d.append(b);b=$('<div class="ui-block-b">');b.append(a);c.append(d);c.append(b);this.html.append(c)}var maxlayers=5,maxresults=40,baseinfo=[];searchUrl="mod_mapbender/search_proxy.php?languageCode=de&resultTarget=web&maxResults="+maxresults;
function addmyLayer(){OpenLayers.Control.Click=OpenLayers.Class(OpenLayers.Control,{defaultHandlerOptions:{single:!0,pixelTolerance:0,stopSingle:!1},initialize:function(a){this.handlerOptions=OpenLayers.Util.applyDefaults((a||{}).handlerOptions||{},this.defaultHandlerOptions);OpenLayers.Control.prototype.initialize.apply(this,arguments);this.handler=new OpenLayers.Handler.Click(this,{click:this.onClick},this.handlerOptions)},onClick:function(a){var b=map.getLonLatFromViewPortPx(a.xy),c=$("#ownlist").find(".query_checked").parent(),
d=$("#select-lang").val(),e=new OpenLayers.Geometry.Point(b.lon,b.lat),f=new OpenLayers.Geometry.Point(b.lon,b.lat);vector_marker.removeAllFeatures();vector_marker.addFeatures([new OpenLayers.Feature.Vector(e,{},olSearchSymbol),new OpenLayers.Feature.Vector(f,{},olFeaturequerySymbol)]);e="p"===$("#select-feature-info").val()?!0:!1;!0==e?setMarkerhint(window.lang.convert("Meldung:"),window.lang.convert("bitte warten...")):0==c.length?setMarkerhint(window.lang.convert("Meldung:"),window.lang.convert("bitte warten...")):
-$.mobile.changePage($("#featureinforesult"),pageTransition);$("#featurelist").empty();if(0<c.length)for(b=0;b<c.length;b++){if(d=c,1<c.length&&(d=$(c[b])),0<d.find(".layer_checked").length){var f=d.attr("getmapurl")+"&SERVICE=WMS&REQUEST=getFeatureInfo&VERSION=1.1.1&mapfile="+d.attr("name")+"&layers="+d.attr("name")+"&QUERY_LAYERS="+d.attr("name")+"&SRS="+featurequerySrc+"&BBOX="+map.getExtent().toBBOX()+"&WIDTH="+map.size.w+"&HEIGHT="+map.size.h+"&X="+a.xy.x+"&Y="+a.xy.y+"&INFO_FORMAT=text/html&FORMAT=image/png&STYLES=",
-g=d.attr("getmapurl")+"service=wms&version=1.1.1&request=GetLegendGraphic&format=image/png&layer="+d.attr("name");featureValid(new FeatureResult(d.attr("title"),layerInList($("#ownlist"),d.attr("layerid")),f,g));e?(d=$('<iframe src="'+f+'" class="query_iframe"><p>Die Abfrage kann leider nicht angezeigt werden.</p></img>'),setMarkerhint("Abfrageergebnis:",d)):(d=$('<iframe src="'+f+'" class="query_iframe_full"><p>Die Abfrage kann leider nicht angezeigt werden.</p></img>'),$("#ficontentdiv").text(""),
-$("#ficontentdiv").append(d))}}else f="query/rasterqueryWms.php?coord="+b.lon+", "+b.lat+"&lang="+d,loadFeature(f)},CLASS_NAME:"OpenLayers.Control.Click"});$("#mapbenderbut").click(function(){$.mobile.changePage($("#mod_mapbender"),pageTransition);refresh()});$("#mapbendersearchformbut").click(function(){searchMaps(searchUrl+"&searchText="+$("#mapbendersearchfield").val())});$(document).on("keypress","#mapbendersearchfield",function(a){13===a.keyCode&&searchMaps(searchUrl+"&searchText="+$("#mapbendersearchfield").val())});
-$(document).on("expand","div[data-role=collapsible]",function(){$("div[data-role=collapsible]").not($(this)).trigger("collapse")});$(".addToMapBut").click(function(){$("div[data-role=collapsible]").not(".ui-collapsible-collapsed").trigger("collapse");$.mobile.changePage($("#mappage"),pageTransition)});addBaselayers()}function addFeatureCallback(a){$("#featurelist").append(a.html);refreshFeatureResults()}
+$.mobile.changePage($("#featureinforesult"),pageTransition);$("#featurelist").empty();getHeight(b.lon,b.lat,d);if(0<c.length)for(b=0;b<c.length;b++){if(d=c,1<c.length&&(d=$(c[b])),0<d.find(".layer_checked").length){var f=d.attr("getmapurl")+"&SERVICE=WMS&REQUEST=getFeatureInfo&VERSION=1.1.1&mapfile="+d.attr("name")+"&layers="+d.attr("name")+"&QUERY_LAYERS="+d.attr("name")+"&SRS="+featurequerySrc+"&BBOX="+map.getExtent().toBBOX()+"&WIDTH="+map.size.w+"&HEIGHT="+map.size.h+"&X="+a.xy.x+"&Y="+a.xy.y+
+"&INFO_FORMAT=text/html&FORMAT=image/png&STYLES=&FEATURE_COUNT=100",g=d.attr("getmapurl")+"service=wms&version=1.1.1&request=GetLegendGraphic&format=image/png&layer="+d.attr("name");featureValid(new FeatureResult(d.attr("title"),layerInList($("#ownlist"),d.attr("layerid")),f,g));e?(d=$('<iframe src="'+f+'" class="query_iframe"><p>Die Abfrage kann leider nicht angezeigt werden.</p></img>'),setMarkerhint("Abfrageergebnis:",d)):(d=$('<iframe src="'+f+'" class="query_iframe_full"><p>Die Abfrage kann leider nicht angezeigt werden.</p></img>'),
+$("#ficontentdiv").text(""),$("#ficontentdiv").append(d))}}else f="query/rasterqueryWms.php?coord="+b.lon+", "+b.lat+"&lang="+d,loadFeature(f)},CLASS_NAME:"OpenLayers.Control.Click"});$("#mapbenderbut").click(function(){$.mobile.changePage($("#mod_mapbender"),pageTransition);refresh()});$("#mapbendersearchformbut").click(function(){searchMaps(searchUrl+"&searchText="+$("#mapbendersearchfield").val())});$(document).on("keypress","#mapbendersearchfield",function(a){13===a.keyCode&&searchMaps(searchUrl+
+"&searchText="+$("#mapbendersearchfield").val())});$(document).on("expand","div[data-role=collapsible]",function(){$("div[data-role=collapsible]").not($(this)).trigger("collapse")});$(".addToMapBut").click(function(){$("div[data-role=collapsible]").not(".ui-collapsible-collapsed").trigger("collapse");$.mobile.changePage($("#mappage"),pageTransition)});addBaselayers()}function addFeatureCallback(a){$("#featurelist").append(a.html);refreshFeatureResults()}
+function getHeight(a,b,c){$.ajax({type:"GET",url:"query/rasterqueryWms.php?coord="+a+", "+b+"&lang="+c,success:function(a){if(a){5>a.length&&(a=window.lang.convert("Kein Ergebnis!"));var b=$("<div>"),c=$('<div class="collapsible unselected" data-role="collapsible" data-collapsed="true" data-theme="a" data-content-theme="c" data-inline="true" data-inset="true"></div>');c.append("<h3>DHM</h3>");c.append(a);b.append(c);$("#featurelist").prepend(b);refreshFeatureResults()}}})}
function featureValid(a){$.ajax({url:"map.php",type:"POST",data:{feature_url:a.url},success:function(b){"true"==b.split("\n")[0]&&addFeatureCallback(a)}})}
function preview(a,b,c){$.ajax({previewurl:a,layerid:b,bbox:c,success:function(){$("#preview").find("div[data-role=content]").empty();$("#preview").find("div[data-role=content]").append('<img src="'+$(this).attr("previewurl")+'" alt="image" style="width:200px;">');var a=$(this).attr("bbox"),b=$(this).attr("layerid");$("#preview_zoom").click(function(){getOpenlayersIndex(b);zoomToBbox(a);$.mobile.changePage($("#mappage"),pageTransition)});$("#preview").popup("open")}})}
getInfo=function(a){$("#info_content").empty();$("#info_content").append(a);$("#info").popup("open")};function getOpenlayersIndex(a){for(var b=0;b<map.layers.length;b++)if(map.layers[b].name==a)return b;return-1}function addOpenlayer(a,b,c){a=new OpenLayers.Layer.WMS(a,c,{layers:b,format:"image/png",transparent:"TRUE",transitionEffect:"resize"},{projection:mapProj,units:projUnits,opacity:0.8,singleTile:!0,isBaseLayer:!1,visibility:!0,alwaysInRange:!0});map.addLayer(a);map.setLayerIndex(a,0)}
@@ -50,13 +51,16 @@
function setQueryable(a,b){b?$(a).find(".query_queryable").addClass("query_checked").removeClass("query_noinfo"):$(a).find(".query_queryable").addClass("query_noinfo").removeClass("query_checked").removeClass("query_unchecked")}function setQueryCheck(a,b){b?$(a).find(".query_queryable").addClass("query_checked").removeClass("query_unchecked"):$(a).find(".query_queryable").addClass("query_unchecked").removeClass("query_checked")}
function base_check(a){$("#baselayers").find(".base_checked").addClass("base_unchecked").removeClass("base_checked");$(a).addClass("base_checked").removeClass("base_unchecked")}
function searchMaps(a){$.mobile.showPageLoadingMsg();$("#search_results").empty();$.getJSON(a,function(a){a=parseMapBenderJson(a);appendData(a.services,a.layers,a.nresults);$.mobile.hidePageLoadingMsg();a.nresults>maxresults&&getInfo("Es gab "+a.nresults+" Treffer, es k\u00f6nnen aber nur "+maxresults+" Ergebnisse angezeigt werden.</br><b>Schr\u00e4nken Sie Ihre Suche weiter ein.</b>")})}
-function searchWmc(a){$.mobile.showPageLoadingMsg();$("#search_results").empty();$.getJSON(a,function(a){appendWmc(a);$.mobile.hidePageLoadingMsg()})}
+function searchWmc(a){$.mobile.showPageLoadingMsg();$("#search_results").empty();$.getJSON(a,function(a){appendWmc(a);$.mobile.hidePageLoadingMsg()})}function searchLayer(a){$.mobile.showPageLoadingMsg();$("#search_results").empty();appendLayer(a);$.mobile.hidePageLoadingMsg()}
function parseMapBenderJson(a){var b=[],c=[];$.each(a.wms.srv,function(a,e){for(var f=!1,g=0;g<b.length;g++)if(b[g].id==e.id){f=!0;break}!e.logged&&!e.nwaccess&&(f||b.push(e),$.each(e.layer,function(a,b){b.layer?$.each(b.layer,function(a,b){""!=b.name&&c.push([e.id,b])}):""!=b.name&&c.push([e.id,b])}))});return{services:b,layers:c,nresults:a.wms.md.nresults}}
function appendData(a,b,c){$("#resultlist").empty();for(var d=0;d<a.length;d++){var e=a[d];service=Service(e.id,e.title,$(e).attr("abstract"),e.getMapUrl,e.status,""==e.logoUrl?"mod_mapbender/img/defaulicon.png":e.logoUrl,e.symbolLink,e.avail);for(var f=0;f<b.length;f++){var g=b[f],h=g[1];g[0]==e.id&&service.append(ResultLayer(h.id,h.title,h.name,$(h).attr("abstract"),h.previewURL,"1"==h.queryable,e.getMapUrl,h.bbox))}$("#resultlist").append(service)}$("#resultlist").prepend('<li data-theme="b">Suchergebnis: '+
numServices()+" Dienste, "+numResultLayers($("#resultlist"))+" Layer ("+c+" Treffer) </li>");validateLayers();refresh()}
function appendWmcData(a,b,c,d,e){$("#ownlist").empty();for(var f=[],g=0;g<a.length;g++)for(var h=a[g],j=0;j<b.length;j++){var k=b[j],l=k[1];k[0]==h.id&&f.push(OwnLayer(l.id,l.title,l.name,$(l).attr("abstract"),h.title,$(h).attr("abstract"),l.previewURL,"1"==l.queryable,h.getMapUrl,l.bbox,h.avail))}for(g=0;g<c.length;g++)for(j=0;j<f.length;j++)if(c[g].layerId==f[j].attr("layerid")){k=f[j];$("#ownlist").append(k);addOpenlayer(k.attr("layerid"),k.attr("name"),k.attr("getMapUrl"));c[g].active||switchVisibility(k);
-c[g].layerQueryable?(setQueryable(k,!0),setQueryCheck(k,c[g].queryLayer)):setQueryable(k,!1);break}validateLayers();validateArrows();b=d.split(",");a=(new OpenLayers.LonLat(b[0],b[1])).transform(e,mapProj);e=(new OpenLayers.LonLat(b[2],b[3])).transform(e,mapProj);map.zoomToExtent(new OpenLayers.Bounds(a.lon,a.lat,e.lon,e.lat))}function clearOwnlist(){for(var a=$("#ownlist").find(".layer"),b=0;b<a.length;b++)removeLayer(a[b])}
+c[g].layerQueryable?(setQueryable(k,!0),setQueryCheck(k,c[g].queryLayer)):setQueryable(k,!1);break}validateLayers();validateArrows();b=d.split(",");a=(new OpenLayers.LonLat(b[0],b[1])).transform(e,mapProj);e=(new OpenLayers.LonLat(b[2],b[3])).transform(e,mapProj);map.zoomToExtent(new OpenLayers.Bounds(a.lon,a.lat,e.lon,e.lat))}
+function appendLayerData(a,b){$("#ownlist").empty();for(var c=[],d=0;d<a.length;d++)for(var e=a[d],f=0;f<b.length;f++){var g=b[f],h=g[1];g[0]==e.id&&c.push(OwnLayer(h.id,h.title,h.name,$(h).attr("abstract"),e.title,$(e).attr("abstract"),h.previewURL,"1"==h.queryable,e.getMapUrl,h.bbox,e.avail))}g=c[0];$("#ownlist").append(g);addOpenlayer(g.attr("layerid"),g.attr("name"),g.attr("getMapUrl"));"true"==g.attr("queryable")?(setQueryable(g,!0),setQueryCheck(g,!0)):setQueryable(g,!1);validateLayers();validateArrows();
+d=g.attr("bbox").split(",");c=(new OpenLayers.LonLat(d[0],d[1])).transform("EPSG:4326",mapProj);d=(new OpenLayers.LonLat(d[2],d[3])).transform("EPSG:4326",mapProj);map.zoomToExtent(new OpenLayers.Bounds(c.lon,c.lat,d.lon,d.lat))}function clearOwnlist(){for(var a=$("#ownlist").find(".layer"),b=0;b<a.length;b++)removeLayer(a[b])}
function appendWmc(a){for(var b=0;b<a.backGroundLayer.length;b++){var c=a.backGroundLayer[b];if(c.active)for(var d=$("#baselayers").find(".baselayer"),e=0;e<d.length;e++)if($(d[e]).attr("layerids")==c.name){switchVisibility(d[e]);break}}clearOwnlist();var f="";$.each(a.layerList,function(a,b){f=f+","+b.layerId});f=f.substr(1,f.length);$.getJSON(searchUrl+"&resourceIds="+f,function(b){b=parseMapBenderJson(b);appendWmcData(b.services,b.layers,a.layerList,a.wmc.bbox,a.wmc.crs);$.mobile.hidePageLoadingMsg()})}
+function appendLayer(a){clearOwnlist();$.getJSON(searchUrl+"&resourceIds="+a,function(a){a=parseMapBenderJson(a);appendLayerData(a.services,a.layers);$.mobile.hidePageLoadingMsg()})}
function addBaselayers(){$("#baselayers").empty();vector_marker=new OpenLayers.Layer.Vector("Vector Layer",{});gps_marker=new OpenLayers.Layer.Vector("gps_marker",{rendererOptions:{zIndexing:!0}});$("#baselayers").append(BaseLayer("RLP Zusammenstellung",atkis_praes_tms.name));$("#baselayers").append(BaseLayer("Luftbilder",luftbilder.name));$("#baselayers").append(BaseLayer("Keine Hintergrundkarte",grenze_leer.name));map.addLayers([atkis_praes_tms,luftbilder,grenze_leer,vector_marker,gps_marker]);
for(i in baseinfo){var a=baseinfo[i][0],b=baseinfo[i][1];$("#baselayers").append(BaseLayer(a,b));addOpenBaselayer(a,b)}base_check($("#baselayers").find(".baselayer").first())}
var initmap=function(){var a={theme:null,projection:mapProj,units:projUnits,maxExtent:mymapbounds,maxScale:mymaxscale,minScale:myminscale,numZoomLevels:myzoomlevels,scales:myscales,controls:[new OpenLayers.Control.Attribution,new OpenLayers.Control.Navigation({zoomWheelEnabled:!0}),new OpenLayers.Control.KeyboardDefaults,new OpenLayers.Control.TouchNavigation({dragPanOptions:{interval:10,enableKinetic:!0}}),new OpenLayers.Control.ScaleLine({div:document.getElementById("scaleline"),geodesic:!1,maxWidth:100,
Modified: trunk/mapbender/http/extensions/mobilemap/map.php
===================================================================
--- trunk/mapbender/http/extensions/mobilemap/map.php 2015-08-12 09:12:16 UTC (rev 9276)
+++ trunk/mapbender/http/extensions/mobilemap/map.php 2015-08-18 09:45:49 UTC (rev 9277)
@@ -10,11 +10,14 @@
else {
$scaleselect = "true";
}
-
//WMC Anfrage Mapbendermodul
if (isset($_GET['wmcid'])) {
$wmcid = htmlspecialchars($_GET["wmcid"]);
}
+//LayerId Anfrage Mapbendermodul
+if (isset($_GET['layerid'])) {
+ $layerid = htmlspecialchars($_GET["layerid"]);
+}
//Validate parameters for zooming to special extent for WMC
if(isset($_REQUEST["mb_myBBOX"]) && $_REQUEST["mb_myBBOX"] != ""){
//Check for numerical values for BBOX
@@ -134,6 +137,19 @@
<?php } ?>
searchWmc(wmcurl);
<?php } ?>
+ //new for layerid
+ <?php if($layerid != ''){ ?>
+ var layerurl = '<?php echo str_replace("wmcid","layerid",$mapbender_wmcurl).$layerid; ?>';
+ var layerid = '<?php echo $layerid; ?>';
+ //add user defined bbox values if given
+ <?php if(isset($mb_myBBOX) && isset($mb_myBBOXEpsg)){ ?>
+ var layerurl = layerurl+"&mb_myBBOX="+<?php echo "'".$mb_myBBOX."'"; ?>+"&mb_myBBOXEpsg="+<?php echo "'".$mb_myBBOXEpsg."'"; ?>;
+ <?php } ?>
+ //alert("searchlayerinvoked");
+ searchLayer(layerid);//layerurl not needed!
+ <?php } ?>
+
+
});
</script>
</head>
Modified: trunk/mapbender/http/extensions/mobilemap/mod_mapbender/search.js
===================================================================
--- trunk/mapbender/http/extensions/mobilemap/mod_mapbender/search.js 2015-08-12 09:12:16 UTC (rev 9276)
+++ trunk/mapbender/http/extensions/mobilemap/mod_mapbender/search.js 2015-08-18 09:45:49 UTC (rev 9277)
@@ -625,6 +625,17 @@
});
}
+// Suche über Layerid
+function searchLayer(layerid){
+ $.mobile.showPageLoadingMsg();
+ $('#search_results').empty();
+ //$.getJSON(layerid, function(data){
+ appendLayer(layerid);//?
+ $.mobile.hidePageLoadingMsg();
+ //});
+}
+
+
// Parst das JSON-Objekt von MapBender in ein Array [services,layers]
function parseMapBenderJson(json){
// Daten generalisieren
@@ -744,6 +755,42 @@
}
+// Fügt die Layer in das DOM ein
+function appendLayerData(services,layers){
+ $("#ownlist").empty();
+ var ownlayers = [];
+ for(var i=0; i<services.length; i++){
+ var srv=services[i];
+ // Layer zuordnen
+ for(var j=0; j<layers.length; j++){
+ var layer=layers[j];
+ var serviceid=layer[0];
+ var lyr=layer[1];
+
+ if(serviceid==srv.id){
+ ownlayers.push(OwnLayer(lyr.id,lyr.title,lyr.name,$(lyr).attr('abstract'),srv.title,$(srv).attr('abstract'),lyr.previewURL,lyr.queryable=='1',srv.getMapUrl,lyr.bbox,srv.avail));
+ }
+ }
+ }
+ var layer=ownlayers[0];
+ $('#ownlist').append(layer);
+ addOpenlayer(layer.attr('layerid'),layer.attr('name'),layer.attr('getMapUrl'));
+ if (layer.attr('queryable') == "true") {
+ setQueryable(layer, true);
+ setQueryCheck(layer, true);
+ } else {
+ setQueryable(layer, false);
+ }
+ validateLayers();
+ validateArrows();
+ //zoom to layer extent
+ var extend=layer.attr('bbox').split(',');
+ var crs = 'EPSG:4326';
+ //alert(mapProj);
+ var p1 = new OpenLayers.LonLat(extend[0],extend[1]).transform(crs,mapProj);
+ var p2 = new OpenLayers.LonLat(extend[2],extend[3]).transform(crs,mapProj);
+ map.zoomToExtent(new OpenLayers.Bounds(p1.lon, p1.lat, p2.lon, p2.lat));
+}
// Alle ausgewählten Overlays entfernen
function clearOwnlist(){
var layers=$('#ownlist').find('.layer');
@@ -790,8 +837,44 @@
});
}
+// Layer-Daten hinzufügen
+function appendLayer(layerid){
+
+ // Hintergrundkarte auswählen
+ /*for(var i=0; i<json.backGroundLayer.length; i++){
+ var layer=json.backGroundLayer[i];
+ if(layer.active){
+ var layers=$('#baselayers').find('.baselayer')
+ for(var j=0; j<layers.length; j++){
+ if($(layers[j]).attr('layerids')==layer.name){
+ switchVisibility(layers[j]);
+ break;
+ }
+ }
+ }
+ }*/
+ // Parsen der bbox aus wmc
+ //var bbox = json.wmc.bbox;
+ //var crs = json.wmc.crs;
+ // Alle ausgewählten overlays entfernen
+ clearOwnlist();
+ // Layerids für die Abfrage zusammenstellen
+ /*var layerids="";
+ $.each(json.layerList, function(index,layer){
+ layerids=layerids+","+layer.layerId;
+ });
+ layerids=layerids.substr(1,layerids.length);*/
+ // Overlays auswählen
+ $.getJSON(searchUrl+'&resourceIds='+layerid, function(data){
+ // Informationen sammeln und Parsen
+ var datacollection=parseMapBenderJson(data);
+ appendLayerData(datacollection.services,datacollection.layers);
+ $.mobile.hidePageLoadingMsg();
+ });
+}
+
// Hintergrunddaten in Collapsible aufnehmen
function addBaselayers(){
More information about the Mapbender_commits
mailing list