Hi there,
I urgently need help to try and get the mapping up and running here! I am trying to use code converted from the desktop version of the Mapsuite product and incorporate it into the web version.
I have a problem with any code that I seem to use to try to dynamically add layers to a map control. All I seem to get is a grid of pink bordered tiles with a message stating "Object Reference not set to an instance of an object " below it. Using either the code I am using in my app or the one from your example application fail to load with the same result. I am using VS2008 here.
Also, I am having issues displaying markers on a map populated from a database in a way that won't cause a severe performance hit (using java to update the map currently but coupled to a windows standard timer is causing issues). Different issue which may require another post, but I would really appreciate if anyone has any sample code that could actually work and get me up and running on any map, whether the base map is a web based one (google), Mr. Sid, other raster type map.\
Best regards,
Bob
Example Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not Page.IsPostBack) Then
Map1.MapBackground.BackgroundBrush = New GeoSolidBrush(GeoColor.StandardColors.White)
Map1.CurrentExtent = New RectangleShape(-80.5, 68.9, 80, -60.43)
Map1.MapUnit = GeographyUnit.DecimalDegree
Dim gdiPlusImageLayer As New GdiPlusRasterLayer(MapPath("~\Maps\Map1.jpg"))
gdiPlusImageLayer.UpperThreshold = Double.MaxValue
gdiPlusImageLayer.LowerThreshold = 0
Map1.StaticOverlay.Layers.Add(gdiPlusImageLayer)
' The following two lines of code enable the client and server caching.
' If you enable these features it will greatly increase the scalability of your
' mapping application however there some side effects that may be counter intuitive.
' Please read the white paper on web caching or the documentation regarding these methods.
' Map1.StaticOverlay.ClientCache.CacheId = "WorldOverlay"
' Map1.StaticOverlay.ServerCache.CacheDirectory = MapPath("~/ImageCache/" + Request.Path)
End If
End Sub
End Class
Code I am using:
Private Sub Open_Raster_Map(ByVal MpPath As String)
If mapOverlay.Layers.Contains(MapPath(MpPath)) Then
mapOverlay.Layers.Remove(MapPath(MpPath))
End If
tgMap.MapUnit = GeographyUnit.DecimalDegree
Dim mapLayer As New GdiPlusRasterLayer(MapPath(MpPath))
mapLayer.UpperThreshold = Double.MaxValue
mapLayer.LowerThreshold = 0
'tgMap.BackgroundOverlay.IsVisible = False
mapLayer.Name = MapPath(MpPath)
mapLayer.Open()
mapOverlay.Layers.Add(MapPath(MpPath), mapLayer)
tgMap.CurrentExtent = GetFullExtent()
tgMap.CustomOverlays.Add(mapOverlay)
'tgMap.Refresh()
End Sub