Map doesn´t show shapes if update panel exists

Last post 8/28/2008 7:11:07 AM by Luftbus320. 2 replies. << Back to Web.Maps.VE v2.0 General
8/26/2008 5:32:11 PM
Luftbus320

Map doesn´t show shapes if update panel exists

Hello Chris,

i got a very strange behavior with the v2.01 map:
When no update panel is involved everything works as expected, but as soon as an update panel exists on the page, the map doesn´t update. The shape exists in the map but won´t show up.

I prepared a small example:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="Simplovation.Web.Maps.VE" Namespace="Simplovation.Web.Maps.VE"
    TagPrefix="Simplovation" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="scm" runat="server"></asp:ScriptManager>
       <asp:LinkButton ID="btnUp" runat="server" Text="update" OnClick="btnUp_Click" />
            
       <%--<asp:UpdatePanel ID="upd" runat="server" UpdateMode="Conditional">
        <ContentTemplate></ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnUp" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>--%>
    <Simplovation:Map ID="Map1" runat="server" OnClientMapLoaded="mapLoaded" />
      
          
 
<script type="text/javascript">
    function mapLoaded()
    {
        var map = $find("<%=Map1.ClientID%>");
       
        var locations = new Array();
        for(var a = 0; a < map.get_Map().GetShapeLayerCount(); a++)
        {
            for(var b = 0; b < map.get_Map().GetShapeLayerByIndex(a).GetShapeCount(); b++)
            {
                Array.addRange(locations, map.get_Map().GetShapeLayerByIndex(a).GetShapeByIndex(b).GetPoints());
            }
        }
        if (locations.length != 0)
            map.get_Map().SetMapView(locations);
    }
</script>

   
   
    </div>
    </form>
</body>
</html>


the code behind:

using System;
using Simplovation.Web.Maps.VE;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnUp_Click(object sender, EventArgs e)
    {
        Map1.AddShape(new ShapeData(new LatLong(54.21, 13.21)));
    }
}


The Sample Website works fine. But what is wrong with my code?

greetings from germany

Kevin
8/27/2008 10:54:28 PM
Chris Pietschmann

Re:Map doesn´t show shapes if update panel exists

I had to make one change, you are trying to create an instance of ShapeData, so I just changed it to Shape, and your code works fine for me. You can't see the Shape right away when it's added since it's plotted outside of the viewable area of the map. Just move the map over and you'll see the Shape plotted where you told it.
8/28/2008 7:11:07 AM
Luftbus320

Re:Map doesn´t show shapes if update panel exists

Hello Chris,

thanks for your reply! Seems Intellisense offered me one of my subclasses of Shape. It works with shape now, but I guess it should work with ShapeData, too (Liskov type substitutuion).

Thanks for your help.

greetings

Kevin