Hi,
I have a layer with features that are drawn from ZoomLevel13 to ZoomLevel20.
I also allow users to click in my map, and if they are near a feature, a pop-up will appear with more information about the selected feature.
When my map is in ZoomLevels1-12, the user can still click on the map, and if they are near one of these features, they will still receive this pop-up. Is there a way to make it so that the features only can be selected if the user is in the right ZoomLevels? In other words, I only want the pop-up to appear when the features are visible on the map.
Thanks,
Treasa
Prevent Feature From Being Clicked Based on Zoom Level
Hi Treasa,
What’s the click events you are using? Server side or client side? If the server side post-back event, I guess what you can do is checking the map’s current zoom level. For client side, you can using the code as following to check:
var mapClick=function(e){
var map = Map1.GetOpenLayersMap();
var zoomLevel = map.getZoom();
if(zoomLevel < 12){
return;
}
}
just something like this. Please have a try and any problem please let us know.
Thanks,
Johnny
Hi Johnny,
I am using server-side. Is this the right way to do it: thinkgeo.com/forums/MapSuite/tabid/143/aft/4731/Default.aspx or is there an easier/more up-to-date way?
Thanks,
Treasa
Hi Treasa,
Please try following
code to prevent click event when ZoomLevel is lower than ZoomLevel12.
protected
void
Map1_Click(
object
sender, MapClickedEventArgs e)
{
if
(Map1.CurrentScale > Map1.ZoomLevelSet.ZoomLevel13.Scale)
{
return
;
}
else
{
Console.WriteLine(
"Do something"
);
}
}
Hope this will be
helpful for you. If any question, please feel free to let us know.
Thanks,
kevin
Hi Kevin,
That worked!
Thank you,
Treasa
Hi Treasa,
I’m glad I was able to help and any question please feel free to let us know.
Regards,
Kevin