ThinkGeo.com    |     Documentation    |     Premium Support

Deployment Problem

I'm having some strange issues when I deploy my web application to our test server.


The map page will take as input a number that will result in a series of zip codes being retrieved from our database. Once these are retrieved I open the pertinent zip code map files that we purchased from ThinkGeo to load each zip code as a feature. Each time I retrieve a zip code feature I merge it with the existing zip code feature(s) already loaded, ending with a single unified feature from several zip codes. In development within the VS2008 IDE this works splendidly.


When I deployed the application to our test server I discovered two strange behaviors:


1. When the data is entered and the button clicked to invoke the process it appears to successfully complete but no feature is displayed. I can tell that it generated the feature properly because it zooms to the correct extent when the merge process is complete. But the feature can't be seen. Strange.


2. When I click and drag the map to scroll it, as soon as I release it the map blanks and fills with a shade of pink, with a small "broken image" X in the top left corner. This also happens if I click the control to zoom. The background map is a Google Map, for which I have an API key. It shows up on the first map request just fine but if I zoom or move it blanks with a pink fill. Very strange.


Any suggestions greatly appreciated.


Bob Mc.



Bob,  
  
 We used to have this kind of issue in some certain browsers with our previous editions. Could you first make sure you are using the latest edition (File Version: 3.0.2) and if the problem still exists, please let me know:  
  
 1, what is the web browser and what’s the operation system for your test server. 
 2, can you provide some info for us to recreate this issue? Such as the data, some pieces of code and some configuration notes. Please send to support@thinkgeo.com and ask to forward to Ben if there is any credential stuff. 
  
 Ben 
 

I verified that the assemblies for WebEdition.dll and MapSuiteCore.dll are version 3.0.2.0. The NetTopology assembly is version 1.7.1.27881.


The server is Windows Server 2003 with SP2, 4GB of RAM, 2 3GHz Dual-core Xeons, IIS6.


The browser I'm using is IE7 with latest service packs. Will try some other combinations.


The source code may not help much without associated database, but I'll try to send what I can to the address provided.


Bob Mc.



Bob, 
  
 Your assemblies seem up to date and the environment is very typical, in fact Windows 2003 is the one we test most with. Can you do a test to simplify the code to see if the problem still exists? If yes please send the new project to us and we will have some further test. 
  
 When the button is clicked, it does some calculations (like merging the features) and returns the features or rectangle for displaying. Can we first comment out the calculation part and just simply return some fixed features or rectangles, just see if the issue has something to do with the merging part. 
   
 After that, the sample will be quite simple, just a map with a button which returns some new features or rectangle to redraw the map. If that sample still doesn’t work, send that to me and we will have a try here. 
  
 By the way on the browser do you see any JavaScript warning in the lower left?  I wonder if the request is taking to long.  I think David sent you some code to speed it up. 
  
 Ben 
 

Ben, below is sample code that now reproduces the problem in development. Thanks for you help.


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register assembly="WebEdition" namespace="ThinkGeo.MapSuite.WebEdition" tagprefix="cc1" %>


w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


w3.org/1999/xhtml">



    Untitled Page





    <form> id="form1" runat="server">

    

        <asp:ScriptManager ID="ScriptManager1" runat="server">

        </asp:ScriptManager>


        <asp:UpdatePanel runat="server" ID="upnlMap" UpdateMode="Conditional">

            <ContentTemplate>

                <cc1:Map ID="ctlDirMap" runat="server" height="768px" width="1024px"></cc1:Map>

                <asp:Button runat="server" ID="btnShow5295" Text="Show Dir #5295" />

            </ContentTemplate>

        </asp:UpdatePanel>

    

    </form>






Imports System.Collections

Imports ThinkGeo.MapSuite.Core

Imports ThinkGeo.MapSuite.WebEdition


Partial Class _Default

    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then

            ctlDirMap.MapUnit = GeographyUnit.DecimalDegree


            ctlDirMap.PanZoomBar.Enabled = True

            ctlDirMap.LayerSwitcher.Enabled = True

            ctlDirMap.MousePosition.Enabled = True


            ctlDirMap.BackgroundMap.YahooMap.Name = "Yahoo Demo"

            ctlDirMap.BackgroundMap.YahooMap.YahooMapType = YahooMapType.Regular


            ctlDirMap.CurrentExtent = New RectangleShape(-94.64456, 39.13578, -94.4674, 39.03605)

        End If

    End Sub


    Protected Sub btnShow5295_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShow5295.Click

        Dim gistList() As Integer = { _

                1208, 1211, 1067, 1068, 1069, 1216, 1221, 1222, 1223, 1224, 1228, 1231, _

                1233, 1234, 1241, 1070, 1242, 1243, 1244, 1252, 1254, 1255, 1256, 1257, _

                1258, 1259, 1260}


        Dim lastUSState As String = String.Empty

        Dim zipMapSourcePath As String = ConfigurationManager.AppSettings("zipMapPath")

        Dim zipSource As ShapeFileFeatureSource = Nothing

        Dim featureCnt As Integer = 0

        Dim zipShapes As New System.Collections.ObjectModel.Collection(Of AreaBaseShape)

        Dim zipFeature As Feature


        Try

            Dim stopWatch As New System.Diagnostics.Stopwatch

            stopWatch.Start()


            zipSource = New ShapeFileFeatureSource("C:\Source\SMG\DMOE2\Web Source\DMOE\Mapping\MapFiles\CA\CAzcta5cu.shp")

            zipSource.Open()


            For Each gist As Integer In gistList

                featureCnt += 1


                zipFeature = zipSource.GetFeatureById(gist.ToString, New String() {"GIST_ID", "COUNTY", "ZCTA"})

                zipFeature.ColumnValues.Add("DIRNUM", String.Format("{0:000000}", 5295))

                zipShapes.Add(zipFeature.GetShape())


            Next


            zipSource.Close()


            Dim combinedZips As MultipolygonShape = AreaBaseShape.Union(zipShapes)


            System.Diagnostics.Debug.WriteLine("Elapsed milliseconds = " & stopWatch.ElapsedMilliseconds)


            Dim mapShapeLayer As New InMemoryLayer

            mapShapeLayer.Open()

            mapShapeLayer.Name = "D5295"

            mapShapeLayer.FeatureSourceColumns.Add(New FeatureSourceColumn("GIST_ID", "Integer", 8))

            mapShapeLayer.FeatureSourceColumns.Add(New FeatureSourceColumn("COUNTY", "String", 5))

            mapShapeLayer.FeatureSourceColumns.Add(New FeatureSourceColumn("ZCTA", "String", 5))

            mapShapeLayer.FeatureSourceColumns.Add(New FeatureSourceColumn("DIRNUM", "String", 6))

            mapShapeLayer.Features.Add("5295", New Feature(combinedZips, "5295"))

            mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.FromArgb(255, GeoColor.SimpleColors.Black)

            mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(150, GeoColor.SimpleColors.Gold)

            mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City1("DIRNUM")

            mapShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

            mapShapeLayer.Close()


            ctlDirMap.DynamicLayers.Add("D5295", mapShapeLayer)


            mapShapeLayer.Open()

            ctlDirMap.CurrentExtent = mapShapeLayer.GetBoundingBox()

            mapShapeLayer.Close()


        Catch ex As Exception

            Response.Write("Error occurred in map generation - " & ex.Message)

        End Try


    End Sub

End Class

 


Bob Mc.



Bob,


Thanks for the code which helps us to recreate the problem.
 
The source of the issue is the text labeling. The following code
 
mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City1("DIRNUM")
 
tries to let the map know we want to label the record with the text in column “DIRNUM”. But however, there do not have any info in that Column when we add the feature (with the following code). So internally it throws an exception which leads to this issue.
 
mapShapeLayer.Features.Add("5295", New Feature(combinedZips, "5295")).
 
 
We will remove the internal exception and solve this problem when the beta refreshes next time. For now we can add a function to make sure all the labeling text is not Nothing, to avoid that exception and solve the problem.
 

Here as following is the code, hope it helps.
 
Ben
 

‘Add a Function, which will make sure all the labeling text is not Nothing
 
Private Sub MakeSureLabelTextAreNotNull(ByVal features As IDictionary(Of String, Feature), ByVal columnName As String)
 
        For Each feature As KeyValuePair(Of String, Feature) In features
            If Not feature.Value.ColumnValues.ContainsKey(columnName) Then
                feature.Value.ColumnValues.Add(columnName, String.Empty)
            ElseIf feature.Value.ColumnValues(columnName) = Nothing Then
                feature.Value.ColumnValues(columnName) = String.Empty
            End If
        Next
 
End Sub

 

‘Call the method when setting the text style
mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City1("DIRNUM")
MakeSureLabelTextAreNotNull(mapShapeLayer.Features, "DIRNUM")

Thanks for the heads-up Ben. Your workaround solved the problem with scrolling/zooming. I also worked around the problem by ensuring the DIRNUM column was there with a value by adding a dictionary of column values to the feature when I add it to the layer, like so:


            Dim dict As New System.Collections.Generic.Dictionary(Of String, String)

            dict.Add("DIRNUM", "5295")


            mapShapeLayer.Features.Add("5295", New Feature(combinedZips, "5295", dict))

 


However, it does not solve the problem I'm having where the feature itself is now shown. It zooms to the proper extent, so it apparently knows the feature exists and its correct size, but it's not displayed on the map. Any help there?


Thanks,


Bob Mc.



Bob,


 Using the original codes with your changes works fine here. Here is the VB code as well as the result snapshot. Could you please have a try on your machine and if problem still exists, send us a snapshot and a file of the exact code?
 
Ben,

47-VBCodeForBob.txt (4.17 KB)

Thanks, I found the problem. While researching the issue with the map background disppearing I set the zoom level to 09 and forgot to set it back. Thanks for the all the help, everything looks good now.


Bob Mc.



Thanks for letting us know and we are gload to help you for any more queries.