Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select specific layer and feature by passing value to flexible layout (AIMS2014)

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
reno.sun.gis
1624 Views, 5 Replies

Select specific layer and feature by passing value to flexible layout (AIMS2014)

5 REPLIES 5
Message 2 of 6
gluckett
in reply to: reno.sun.gis

Hi,

I don't think the map.query is implemented anymore.

http://trac.osgeo.org/fusion/wiki/Cookbook/Map/Query

 

Instead, you may have to use the Web API to select the object, return the Selected XML and use that to highlight and zoom to the obect.

 

 

Message 3 of 6
reno.sun.gis
in reply to: gluckett

Hello, 

 

Finally, I solve my this issue. 

 

I post my solution in the end of the post here: http://osgeo-org.1560.x6.nabble.com/Select-specific-layer-and-feature-by-passing-value-to-flexible-l...

 

Thank you for your reply 🙂

 

Message 4 of 6
gluckett
in reply to: reno.sun.gis

Hi, I put the solution to the auto-zoom to feature on load for Flexible Web Layouts here (http://mapguide.wordpress.com/2013/06/11/autodesk-infrastructure-map-server-auto-zoom-on-load/)

 

You can pass:

  • LAYERNAME (i.e. Parcels)
  • KEYNAME (i.e. ID or ADN)
  • KEY (ie. 1234 or 444)
  • ISSTRING (0 or 1) 

 

For example, this selects 2 roads in Sheboygan with an ID or 644 and 684:

http://localhost/mapserver2014/fusion/templates/mapguide/slate/index.html?LAYERNAME=Roads&KEYNAME=ID...

 

The example uses SLATE but it can use any Flexible Web Layout you wish.

 

Remember, "LOCALHOST" is just a trick to call your own computer as a server, usually you would use the actual name of your server.

 

Message 5 of 6
reno.sun.gis
in reply to: reno.sun.gis

For the fusion users, I think this is the simplest solution!

http://autodesk.typepad.com/beyondthebox/2012/09/application-integration-with-autodesk-infrastructur... 

If you would like to select features by attribute values 🙂

Message 6 of 6
reno.sun.gis
in reply to: reno.sun.gis

For the fusion users, I think this is the simplest solution!

http://autodesk.typepad.com/beyondthebox/2012/09/application-integration-with-autodesk-infrastructur...

If you would like to select features by attribute values 🙂

Moreover, Gordon provided a very neat solution for user would like to select specific layer and feature by primary key too!!!

https://mapguide.wordpress.com/2013/06/11/autodesk-infrastructure-map-server-auto-zoom-on-load/

BTW, I use Gordon's solution for my "Kaliopa Mapguide Mobile Viewer" to allow user select specific features by passing value through the URL.

However, you will face a "zoom to object" issue for point features. Great news is people have already built some solutions for it.

http://osgeo-org.1560.x6.nabble.com/Zoom-to-selected-feature-point-doesn-t-work-td5095926.html

If you're using fusionSF.js like me, you can add the code as following under the renderSelection function:
...
renderSelection: function (zoomTo, r) {
...
if (zoomTo) {
var ext = oNode.extents;
//Reno's custom zoom for points
if (ext != null) {
if (ext.minx == ext.maxx) {
this.setExtZoom(ext, 100);
}

var extents = new OpenLayers.Bounds(ext.minx, ext.miny, ext.maxx, ext.maxy);
this.mapWidget.setExtents(extents);
}
}
...
},
setExtZoom: function (ext, zoomFactor) {
ext.minx = ext.minx - zoomFactor / 2;
ext.miny = ext.miny - zoomFactor / 2;
ext.maxx = ext.maxx + zoomFactor / 2;
ext.maxy = ext.maxy + zoomFactor / 2;
},
...

If you are using "Kaliopa Mapguide Mobile Viewer" with Gordon's solution you will probably would like to add/update following codes under Default.debug.js or Default.min.js:

//Gordon's code
function zoomToObject(sessionId, mapName) {
if (getParam('action' == 'zoom')) {
var SESSION = sessionId;
var MAPNAME = mapName;


var KEY = getParam('KEY');
var ISSTRING = getParam('ISSTRING');
var KEYNAME = getParam('KEYNAME');
var LAYERNAME = getParam('LAYERNAME');

if (KEY != null || KEY != '') {
//The GETSELECTIONXML.php returns the XML of selected features.
var AJAXURL = "/mapserver2014/GETSELECTIONXML.php?MAPNAME=" + MAPNAME;
AJAXURL = AJAXURL + "&SESSION=" + SESSION;
AJAXURL = AJAXURL + "&KEYNAME=" + KEYNAME;
AJAXURL = AJAXURL + "&LAYERNAME=" + LAYERNAME;
AJAXURL = AJAXURL + "&KEY=" + KEY;
AJAXURL = AJAXURL + "&ISSTRING=" + ISSTRING;

var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
SetSelectionXML(xmlhttp.responseText);
ZoomSelection();
MultiGridShow();
}
}
xmlhttp.open("GET", AJAXURL, true);
xmlhttp.send();
}
}
}

For zoom problems of point and linear features, modify the code under the ZoomSelection function:

//Modify the extent/zoom level based on your custom needs. You can create some formula for your geographic data :)
function ZoomSelection() {
...
if (dr.status == 200) {
var env = ParseEnvelope(dr.responseXML.documentElement);
//alert(env.lowerLeft.X + ',' + env.lowerLeft.Y + ',' + env.upperRight.X + ',' + env.upperRight.Y);
if (env != null) {
//var extentSel = new OpenLayers.Bounds(env.lowerLeft.X, env.lowerLeft.Y, env.upperRight.X, env.upperRight.Y);
var extentSel = new OpenLayers.Bounds(env.lowerLeft.X, env.lowerLeft.Y, env.upperRight.X, env.upperRight.Y);
var sc = (env.upperRight.X - env.lowerLeft.X);
if (sc == 0) {
var pointextentSel = new OpenLayers.Bounds(env.lowerLeft.X, env.lowerLeft.Y - 40, env.upperRight.X + 10, env.upperRight.Y + 10);
var cntL = new OpenLayers.LonLat(env.lowerLeft.X, env.lowerLeft.Y);
map.setCenter(cntL, 1);
map.zoomToExtent(pointextentSel);
}
else if (sc < 10) {
extentSel = new OpenLayers.Bounds(env.lowerLeft.X, env.lowerLeft.Y - 50, env.upperRight.X, env.upperRight.Y);
map.zoomToExtent(extentSel);
map.zoomToScale(2500, true);
}
else {
extentSel = new OpenLayers.Bounds(env.lowerLeft.X, env.lowerLeft.Y - 50, env.upperRight.X, env.upperRight.Y);
map.zoomToExtent(extentSel);
}
}
}
}

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report