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 all features on a map layer

1 REPLY 1
Reply
Message 1 of 2
Anonymous
179 Views, 1 Reply

Select all features on a map layer

My function below only selects 2 features on my map instead of the 30+ it should. If I change the layer name (from "Tanks" to "Pumps" for example) only 1 map feature is selected -- in a totally different area of the map!

I have set the "getMapExtent" method to return the entire map area in lat/lon coords (false, false).
My map is in Arbitrary *XY-Ft* coords, yet even when i try a (false, true) argument to return the MCS points, the same getMin/getMax values are returned.

The selectPolygonEx method below is returning true, indicating that the values passed to it are valid
argument types.

After some initial problems, I feel I'm now on the right track with this routine, and very close to completing it. Can anybody out there please pinpoint my problem?

Thank you,

Mark Sanchez

// function to select all map features
function selectall()
{
var map = getMap();
var layer = map.getMapLayer("Tanks");

map.setAutoRefresh(false);
// returns MGExtentEx bounding box for entire map in lat/lon values
var mapext = map.getMapExtent(false, false); // (false, true) yields same getMin/getMax values

var llpt = map.createObject("MGPoint");
llpt.setX(mapext.getMinX()); // lon
llpt.setY(mapext.getMinY()); // lat

var urpt = map.createObject("MGPoint");
urpt.setX(mapext.getMaxX()); // lon
urpt.setY(mapext.getMaxY()); // lat

var bbox = map.createObject("MGCollection");
bbox.add(llpt); // lower left
bbox.add(urpt); // upper right

var bsel = map.selectPolygonEx(layer, bbox);

map.setAutoRefresh(true);
map.refresh();

if (bsel == true)
alert("Success");
else
alert("Failure");
}
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

Hi,

As far as I understood your aim is to select all
objects in a layer that are currently visible in a map. If so than you
could


 "Returns a Vector (or
href="http://www.mapguide.com/help/ver6/api/en/MGCollection_intro.htm">MGCollection

object) containing the map features of the layer that fall within the map extent
(the part of the map that is displayed).

"

(or method getMapObjectsEx).

 

Then you could add this collection to current selection

Regards

Evgeny


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
My
function below only selects 2 features on my map instead of the 30+ it should.
If I change the layer name (from "Tanks" to "Pumps" for example) only 1 map
feature is selected -- in a totally different area of the map!

I have set the "getMapExtent" method to return the entire map area in
lat/lon coords (false, false).
My map is in Arbitrary *XY-Ft* coords, yet
even when i try a (false, true) argument to return the MCS points, the same
getMin/getMax values are returned.

The selectPolygonEx method below is returning true, indicating that the
values passed to it are valid
argument types.

After some initial problems, I feel I'm now on the right track with this
routine, and very close to completing it. Can anybody out there please
pinpoint my problem?

Thank you,

Mark Sanchez

// function to select all map features
function selectall()
{

var map = getMap();
var layer = map.getMapLayer("Tanks");

map.setAutoRefresh(false);
// returns MGExtentEx bounding box for
entire map in lat/lon values
var mapext = map.getMapExtent(false, false);
// (false, true) yields same getMin/getMax values

var llpt = map.createObject("MGPoint");
llpt.setX(mapext.getMinX()); //
lon
llpt.setY(mapext.getMinY()); // lat

var urpt = map.createObject("MGPoint");
urpt.setX(mapext.getMaxX()); //
lon
urpt.setY(mapext.getMaxY()); // lat

var bbox = map.createObject("MGCollection");
bbox.add(llpt); // lower
left
bbox.add(urpt); // upper right

var bsel = map.selectPolygonEx(layer, bbox);

map.setAutoRefresh(true);
map.refresh();

if (bsel == true)
alert("Success");
else
alert("Failure");

}

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

Post to forums  

Autodesk Design & Make Report