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: 
Reply
Message 1 of 6
patbeer
197 Views, 5 Replies

Layers

I have 3 particular layers in my mwf. When a layer is clicked on, I want the other two to be switched off.
Does anybody know how to perform this operation, as I have tried so many things. I have managed to alternate between the layers but the points are not visible in the map.
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: patbeer

You'll probably have to use a MapGuide API event to
test for this.  Your best bet will be the onViewChanged() event. 
Have the function check to see if layer 1 has been turned on via the isVisible()
method and then turn the other 2 off via the setVisibility() method.  
You have to refresh() the map after setVisiibility() since it is not done
automatically.

 


--
Andy Morsell, P.E.
Spatial
Integrators, Inc.

href="http://www.spatialgis.com">http://www.spatialgis.com


 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">I
have 3 particular layers in my mwf. When a layer is clicked on, I want the
other two to be switched off.
Does anybody know how to perform this
operation, as I have tried so many things. I have managed to alternate between
the layers but the points are not visible in the map.
Message 3 of 6
patbeer
in reply to: patbeer

Thank you very much for your help as I have put the following code in the OnViewChanged() event.
// only make visible either Property Gazetteer, LLPG or Addresspoint
function turnProperty(map) {
var property = map.getMapLayer("property");
var llpg = map.getMapLayer("llpg");
var addresspoint = map.getMapLayer("addresspoint");

if (property.isVisible() == true) {
property.setVisibility(llpg.getVisibility() || addresspoint.getVisibility());
} else {
if (llpg.isVisible() == true) {
llpg.setVisibility(property.getVisibility() || addresspoint.getVisibility());
} else {
if (addresspoint.isVisible() == true) {
addresspoint.setVisibility(llpg.getVisibility() || property.getVisibility());
}
}
}
}

It toggles between the layers but the labels are not showing, when you hover of the points, also you can not select them. Have you any Ideas.
Message 4 of 6
Anonymous
in reply to: patbeer

What happens if you do a map.refresh() at the
end?

 

Andy


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thank
you very much for your help as I have put the following code in the
OnViewChanged() event.
// only make visible either Property Gazetteer,
LLPG or Addresspoint
function turnProperty(map) {
var property =
map.getMapLayer("property");
var llpg = map.getMapLayer("llpg");
var
addresspoint = map.getMapLayer("addresspoint");

if (property.isVisible() == true) {

property.setVisibility(llpg.getVisibility() ||
addresspoint.getVisibility());
} else {
if (llpg.isVisible() == true)
{
llpg.setVisibility(property.getVisibility() ||
addresspoint.getVisibility());
} else {
if (addresspoint.isVisible()
== true) {
addresspoint.setVisibility(llpg.getVisibility() ||
property.getVisibility());
}
}
}
}

It toggles between the layers but the labels are not showing, when you
hover of the points, also you can not select them. Have you any
Ideas.

Message 5 of 6
dvluijk
in reply to: patbeer

Your code would not execute the exact thing you wanted.

You check your property layer first. If property is active, then the others get turned off. So if the propertylayer is active and you want to make another one active, still the property would remain visible.

What you should do is keep the former state of all the layers its visibility in a variabele. If one is changed from invisible to visible, then you should turn the others off
Message 6 of 6
bjeffers
in reply to: patbeer

dvluijk,
do you have a sample code of what you described?

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

Post to forums  

Autodesk Design & Make Report