Hi,
I’ve finally taken Map Suite v9 into production, but has encountered a strange problem. I’ve just upgraded to the latest build 9.0.0.142, but that didn’t remedy the issue.
I’m wrapping an MsSql2008FeatureLayer in a LayerOverlay, and I want it to be initially not shown. This approach worked like a charm in v5.5.
- If I set LayerOverlay.IsVisible = True, the layer is shown just fine.
- If I set LayerOverlay.IsVisible = False, the layer is not shown, but I can’t turn it on afterwards in the OpenLayers client ??
It’s not a base overlay, and it’s visible in the OverlaySwitcher. It uses SingleTile for TileType.
Please advise.
Cheers.
Lars I Nielsen
WebEdition v9 LayerOverlay display fails
Update:
If I repost the page by some other button, while the layer in question is turned “on”, the data appears in the map. And I can now turn the layer on and off as normally.
But if the repost is done with the layer turned off, I still can’t turn it on in the client.
So it would appear that the error lies within the client code that Map Suite submits to the browser, where clicking a layer’s checkbox on doesn’t do anything.
Cheers.
Hi Lars,
As below is my test code and the screen shot shows this overlay can be find if it’s set as isVisible equal false.
If I missed any point please let me know.
if (!Page.IsPostBack)
{
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.CurrentExtent = new RectangleShape(-125, 72, 50, -46);
Map1.MapUnit = GeographyUnit.DecimalDegree;
LayerOverlay overlay = new LayerOverlay(“MyTestOverlay”);
overlay.IsVisible = false;
MsSql2008FeatureLayer layer = new MsSql2008FeatureLayer();
overlay.Layers.Add(layer);
Map1.CustomOverlays.Add(overlay);
}
Regards,
Don
Hi Don,
Your code seems to be on target:
- MsSql2008FeatureLayer.IsVisible = True
- LayerOverlay.Layers.Add(MsSql2008FeatureLayer)
- LayerOverlay.IsVisible = False 'Initially
It works as expected in the previous version we’re using (5.5), but doesn’t seem to work in v9.
It does work in v9, but only if the overlay is either initially set to visible, or if selected in the client when resubmitting the page.
Please advise.
Addendum: I just tried to run it in Firefox (42.0) instead of the usual IE (11), but it behaved exactly the same as in IE.
Cheers
Lars
Hi Lars,
Yes I have a little confused on that, it looks my test code just like the target you listed.
You can see in my screen shot, the "MyTestOverlay" can be found in client side, the right part in my screen shot is the console of page, call Map1.GetMapParser().map.layer[1] can see it exist.
Are you using some different way to see whether it exist or not? I am using chrome for test.
Regards,
Don
Hi Don,
The solution is viewable online here - hvmgo02.hvenegaard.dk/PumpelagWeb/
After it starts, try to do as follows:
- Swap to the “Kortudsnit” tab
- Turn off the “Jordstykker” layer (topmost with checkbox)
- Swap back to the “Velkommen” tab
- Press the “Vis” button
- See if you can turn the layer “Jordstykkker” on
You can repeat this with the “jordstykker” layer turned on, and see the difference.
Ps! Yes, I still have the v9 license activation on that server on my to-do list ;-)
Cheers.
Lars
Hi Lars,
The link is not accessible, but I think I recreate your issue.
The reason is because when we change the client side layer visibility through LayerSwitcher, it doesn’t inform the server to change the layer visibility in server side, what I am guessing that 5.5 works is because in that version, it will do a postback automatically. But for now, we made a lot of changes and not support this strategy anymore I suppose.
As a workaround, I can figure out two options, both of them will trigger a postback.
- Register a visibilitychanged event for each layer and do a postback to sync the client side status with server side.
<
script
type
=
“text/javascript”
>
OnMapCreated = function (map) {
for (var i = 0; i < map.layers.length; i++) {
var layer = map.layers<i>;
layer.events.register(“visibilitychanged”, this, function (e) {
__doPostBack(“form1”, “”);
});
}
}
- Using asp.net button to change the server side layer visibility.
<asp:Button ID=“Button1” runat=“server” OnClick=“Button1_Click” Text=“Change Visibility” />
protected void Button1_Click(object sender, EventArgs e)
{
if (Map1.CustomOverlays[“WorldOverlay”].IsVisible)
{
Map1.CustomOverlays[“WorldOverlay”].IsVisible = false;
}
else
{
Map1.CustomOverlays[“WorldOverlay”].IsVisible = true;
}
}
Please let us know if any questions.
Thanks,
Troy
Hi Troy,
(We do) “not support this strategy anymore I suppose” !?
Since when is adding a layer(overlay) to ones map without wanting to show it initially a “strategy” ??
As I wrote, it worked previous versions, and it’s a logical thing to want to do, so please incorporate whatever “work-around” is needed in the Javascript that Map Suite submits.
As for the link, we’re in a company transition, and apparently only some of the server names work from the outside. I’m having my IT guy look into it asap.
But try this link instead: hvmgo02.geopartner.dk/PumpelagWeb/
Cheers
Lars
Hi again,
Ok, after correcting the typo (
var layer = map.layers[i];
) the first work around works as such. But not as is to be expected.
Open Layers is a full blown client in its own right, and is capable of turning layers on and off on its own. This is what I’m looking for.
I don’t want - and definitely don’t need - a page postback every time a layer is turned on or off. Nor do I wish to add functionality to any other form item to make it work.
Please look further into this issue, it’s neither productive nor logical as-is. See my previous post for more comments.
Cheers
Lars
Hi Lars,
I looked back on 5.5 and looks there does be a bug in our latest version. I’ve reported to our development team and we will try to fix it ASAP.
Hope we can fix it.
Thanks,
Troy
Lars,
We fixed the issue in latest both dev and prod dll packages, please get the version(9.0.164.0 or higher) to fix it.
Please let us know if any questions.
Thanks,
Troy
Thanks Troy,
I’ll download it when it’s ready.
Cheers
Lars
Hi Lars,
Ok, I’m glad to wait for your reply.
Thanks,
Hi all,
It seems to be working now (in 9.0.167). Thanks :-)
Cheers
Lars
Hi Lars,
We are glad to hear that fixed.
Any question please let us know.
Regards,
Don