ThinkGeo.com    |     Documentation    |     Premium Support

Map current extent issue

Hi,
I am setting map current extent to one layer extent. but it’s not setting exactly to the layer features.

Code:
InMemoryFeatureLayer imRouteLayer = (InMemoryFeatureLayer)((LayerOverlay)wfMap.CustomOverlays[“RouteOverlay”]).Layers[“RouteLayer”];
if (imRouteLayer.InternalFeatures.Count > 0)
{
imRouteLayer.Open();
wfMap.CurrentExtent = imRouteLayer.GetBoundingBox();
imRouteLayer.Close();
}

Please suggest me for fixing it.

Thanks,
Riyaz

Hi Riyaz,

Your code don’t have problem, and I also hadn’t noticed where is the problem only from your text and screen shot.

What you think the layer should looks like? I guess you should want debug your code and see what’s the value of imRouteLayer.GetBoundingBox()

Regards,

Ethan

Hi Ethan,
I got it. Thanks for your reply. I just used ZoomToScale method. it’s fulfill my requirement.

Thanks,
Riyaz

Hi Riyaz,

Thanks for your update, zoomToScale will change the scale and the result won’t fit the default bounding box.

Regards,

Ethan

Hi Ethan,
Actually the issue related to Height in Pixels.
Please check the code

            <Thinkgeo:Map ID="wfMap" Width="100%" Height="100%" runat="server" OnClick="wfMap_Click"  OnDoubleClick="wfMap_DoubleClick" OnExtentChanged="wfMap_ExtentChanged">

So whenever we set Height to 100%, then CurrentExtent was not settling properly.
But when we set Height to 750px, thenn CurrentExtent was working fine its set correctly.

Could you please tell me, is height gonna issue for setting extent. If it’s issue, tell me some suggestions for fixing this issue.

Note: Map is in Update Panel.

Thanks,
Riyaz

Hi Riyaz,

We calculate the extent will via the actual height and actual width of map control, if you set them to 100%, and it contained by other container for example the update panel you mentioned, which means the height when it be calculated maybe not the height when you seen on browser.

We don’t have suggestion about that, but I think you can set the height or width of all the mother container for 100% to see whether it can works well.

Regards,

Ethan

Hi Ethan,

             I kept 100% height for all mother containers of map(html,body,form,update panel).

Even though it’s didn’t work out. Actually I need to use height in 100% because to have same height level in all resolutions.

So could you please find some solution about it. we almost finish all major things, but we want to set proper extent to different situations with CurrentExtent property.

Thanks,
Riyaz

Hi Riyaz,

This a very simple sample, you can modify the code and reproduce the problem for us, I guess the code missed some point in your post.

9014.zip (173.7 KB)

Regards,

Ethan