ThinkGeo.com    |     Documentation    |     Premium Support

How to call a webservice function to get a bitmap and render this bitmap on a web map control in Web 3.0?

.skype_tb_injection {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND: no-repeat 0px 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; WORD-SPACING: normal; BORDER-LEFT: 0px; CURSOR: hand; COLOR: #333333; TEXT-INDENT: 0px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; WHITE-SPACE: nowrap; LETTER-SPACING: 0px; HEIGHT: 16px! important; TEXT-ALIGN: left; WORD-WRAP: break-word
}
.skype_tb_injection .skype_tb_injectionIn {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND: url(file://C:/Users/Kevin/AppData/Local/Temp/Low/__SkypeIEToolbar_Cache/e70d95847a8f5723cfca6b3fd9946506/static/inactive_m.compat.gif) repeat-x 0px 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; CURSOR: hand; COLOR: #333333; TEXT-INDENT: 0px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma, Verdana, Arial, Helvetica, sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important; TEXT-ALIGN: left
}
.skype_tb_injection .skype_tb_innerText {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND: none transparent scroll repeat 0% 0%; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; CURSOR: hand; COLOR: #333333! important; TEXT-INDENT: 0px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma, Verdana, Arial, Helvetica, sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important; TEXT-ALIGN: left
}
.skype_tb_injection .skype_tb_img {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline! important; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; LETTER-SPACING: 0px; POSITION: relative; TOP: 0px; HEIGHT: 16px! important
}
.skype_tb_injection .skype_tb_img2 {
BORDER-RIGHT: white 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: white 1px solid; DISPLAY: inline! important; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: white 1px solid; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: white 1px solid; LETTER-SPACING: 0px; POSITION: relative; TOP: 1px; HEIGHT: 16px! important
}
.skype_tb_injection .skype_tb_imgFlag {
BORDER-RIGHT: white 0px solid; PADDING-RIGHT: 0px; BORDER-TOP: white 0px solid; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: no-repeat 7px 2px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: top; BORDER-LEFT: white 0px solid; WIDTH: 24px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: white 0px solid; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 15px
}
.skype_tb_injection .skype_tb_imgFlagAct {
BORDER-RIGHT: white 0px solid; PADDING-RIGHT: 0px; BORDER-TOP: white 0px solid; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: no-repeat 8px 3px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: white 0px solid; WIDTH: 24px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: white 0px solid; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 15px! important
}
.skype_tb_injection .skype_tb_imgA {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: no-repeat 0px 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; WIDTH: 33px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important
}
.skype_tb_injection .skype_tb_imgS {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: url(file://C:/Users/Kevin/AppData/Local/Temp/Low/__SkypeIEToolbar_Cache/e70d95847a8f5723cfca6b3fd9946506/static/inactive_s.flex.compat.gif) no-repeat 0px 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; WIDTH: 6px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important
}
.skype_tb_injection .skype_tb_imgS_stat {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: url(file://C:/Users/Kevin/AppData/Local/Temp/Low/__SkypeIEToolbar_Cache/e70d95847a8f5723cfca6b3fd9946506/static/inactive_s.stat.compat.gif) no-repeat 0px 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; WIDTH: 1px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important
}
.skype_tb_injection .skype_tb_imgS_noflag {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: url(file://C:/Users/Kevin/AppData/Local/Temp/Low/__SkypeIEToolbar_Cache/e70d95847a8f5723cfca6b3fd9946506/static/inactive_s.flex_noflag.compat.gif) no-repeat 0px 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; WIDTH: 6px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important
}
.skype_tb_injection .skype_tb_imgS_stat_noflag {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: url(file://C:/Users/Kevin/AppData/Local/Temp/Low/__SkypeIEToolbar_Cache/e70d95847a8f5723cfca6b3fd9946506/static/inactive_s.stat_noflag.compat.gif) no-repeat 0px 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; WIDTH: 6px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important
}
.skype_tb_injection .skype_tb_imgR {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: url(file://C:/Users/Kevin/AppData/Local/Temp/Low/__SkypeIEToolbar_Cache/e70d95847a8f5723cfca6b3fd9946506/static/inactive_r.compat.gif) no-repeat 0px 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; WIDTH: 19px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important
}
.skype_tb_injection .skype_tb_imgRfax {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline! important; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 9px; BACKGROUND: url(file://C:/Users/Kevin/AppData/Local/Temp/Low/__SkypeIEToolbar_Cache/e70d95847a8f5723cfca6b3fd9946506/static/inactive_r.compat_fax.gif) no-repeat 0px 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; WIDTH: 19px; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-STYLE: normal; FONT-FAMILY: Tahoma,Verdana,Arial,Helvetica,sans-serif; LETTER-SPACING: 0px; HEIGHT: 16px! important
}
#skype_menu {
BORDER-RIGHT: #666666 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #666666 1px solid; PADDING-LEFT: 5px; Z-INDEX: 101; BACKGROUND: #ffffe1; LEFT: 0px; VISIBILITY: hidden; PADDING-BOTTOM: 3px; MARGIN: 0px; FONT: menu; BORDER-LEFT: #666666 1px solid; WIDTH: auto; CURSOR: pointer; COLOR: #333333; PADDING-TOP: 3px; BORDER-BOTTOM: #666666 1px solid; POSITION: absolute; TOP: 0px
}
#skype_dropdown {
BORDER-RIGHT: #666666 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #666666 1px solid; PADDING-LEFT: 2px; Z-INDEX: 101; BACKGROUND: #ffffff; LEFT: 0px; VISIBILITY: hidden; PADDING-BOTTOM: 2px; MARGIN: 0px; FONT: menu; BORDER-LEFT: #666666 1px solid; WIDTH: auto; CURSOR: hand; COLOR: #333333; PADDING-TOP: 2px; BORDER-BOTTOM: #666666 1px solid; POSITION: absolute; TOP: 0px
}
#skype_frame {
DISPLAY: none; Z-INDEX: 100; LEFT: 0px; MARGIN: 0px; POSITION: absolute; TOP: 0px
}
How to call a webservice function to get a bitmap and render

this  bitmap on a web map control in Web 3.0?

The following is my Web 2.5  code:

Protected Sub Map1_BeforeLayersDraw(ByVal G As  System.Drawing.Graphics)

Handles Map1.BeforeLayersDraw

        Dim  MapMaker As TGMapService.MapService = New

TGMapService.MapService()



         Try

            MapMaker.Credentials  =

System.Net.CredentialCache.DefaultCredentials



            Dim images  As Byte() =

MapMaker.GetMapImage(Map1.CurrentExtent.UpperLeftPoint.X, _

             Map1.CurrentExtent.UpperLeftPoint.Y, _

             Map1.CurrentExtent.LowerRightPoint.X, _

             Map1.CurrentExtent.LowerRightPoint.Y, _

             Convert.ToInt32(Map1.Height.Value), _

             Convert.ToInt32(Map1.Width.Value), _

            -1)

            Dim  MemoryStream As MemoryStream = New MemoryStream(images)

            Dim  NewImage As Bitmap = New Bitmap(MemoryStream)



             G.DrawImageUnscaled(NewImage, 0, 0)

        Catch ex As Exception

             lbMsg.Text = ex.Message

        End Try

    End Sub



Kevin,




 


In the 3.0 system it is better that you wrap this within your own custom Layer. This gives you the flexibility to place it in whatever order you want. Also you will not need to wire up any events. It's a but more object oriented and a little more code. The sample is re-used from another post and the API might not exactly match up with what is in the latest Web Edition. I do suggest you get the latest version which was released yesterday.




 


Later today I will verify that it runs in VB.NET and the Apis are correct for the latest edition. This might be all you need though so let me know of you get it working and I can skip the final details.


I have put together the code for you new custom layer. The first part is how to use it and the second part is the actually new class.


            'Here I create my custom layer

            Dim customLayer as SimpleCustomLayer  = new SimpleCustomLayer()


            'Here I add my cusotm layer to the layers collection.

            Map1.StaticLayers.Add("CustomLayer", customLayer)

 




Imports System 
Imports System.Collections.Generic 
Imports System.Text 
Imports System.Drawing 

' What this sample does is creates your own layer. You can use this layer just like any other layers 
' in the system. The advantage is that you can place it where you want and it will seamlessly integrate 
' with the rest of the system. As you can see it is really easy to create your own layers. 

' The basic flow of events is that when the map needs to draw it will first call the OpenCore. 
' This is where you do anything special to get your source ready. Then it will call the GetBoundingBox 
' method to make sure the current extent of the map is within the are you have data. If not then it will 
' never call the DrawCore because there is no need. Then if you are int he extent it wil call the DrawCore. 
' The DrawCore is where you place your code that need to do the drawing on the canvas. As you can see below 
' it is faily simple. 

Namespace ThinkGeo.MapSuite.Core 
    Class SimpleCustomLayer 
        Inherits Layer 
        
        Dim MapMaker As TGMapService.MapService

        Protected Overloads Overrides Sub OpenCore() 
            ' Here you should do anything you need to do it initilize your source. 
            ' Like --> MapMaker = New TGMapService.MapService() 
        End Sub 
        
        Protected Overloads Overrides Sub CloseCore() 
            ' Here you should do anything you need to do it close your source. I made up the close call.
            ' Like ---> MapMarker.Close()
        End Sub 
        
        
        Protected Overloads Overrides Sub DrawCore(ByVal canvas As GeoCanvas, ByVal labeledInLayers As System.Collections.ObjectModel.Collection) 
            ' Here is where you will call your API. You will get a bitmap back and then draw it in the canvas. 
            ' I have provided a mock method call to simulate what you will do. 
            
            Dim customImage As Bitmap = GetImage(canvas.CurrentWorldExtent.UpperLeftPoint.X, canvas.CurrentWorldExtent.UpperLeftPoint.Y, canvas.CurrentWorldExtent.LowerRightPoint.X, canvas.CurrentWorldExtent.LowerRightPoint.Y, CInt(canvas.CanvasWidth), CInt(canvas.CanvasHeight)) 
            
            ' Here we draw the image you generated to the canvas. 
            canvas.DrawWorldImageWithoutScaling(canvas.ToGeoImage(customImage), canvas.CurrentWorldExtent.GetCenterPoint().X, canvas.CurrentWorldExtent.GetCenterPoint().Y, DrawingLevel.LevelOne) 
            
            customImage.Dispose() 
        End Sub 
        
        Private Function GetImage(ByVal upperLeftX As Double, ByVal upperLeftY As Double, ByVal lowerRightX As Double, ByVal lowerRightY As Double, ByVal screenWidth As Integer, ByVal screenHeight As Integer) As Bitmap 
            ' In here you would get your image and return it. 
            ' I am just returning an image with some text so you can verify it works.. 
            
            Dim customImage As New Bitmap(screenWidth, screenHeight) 
            Dim g As Graphics = Graphics.FromImage(customImage) 
            g.DrawString("SimpleCustomLayer Test", New Font("Arial", 20, FontStyle.Bold), Brushes.Black, New PointF(screenWidth / 2, screenHeight / 2)) 
            g.Dispose() 
            
            Return customImage 
        End Function 
    End Class 
    
End Namespace 
 

David