Hi Ethan,
Sorry for the confusion. My first question is simply we want the circle to be on top of the line. In the image it shows the line on top of the point.
As for the second question, we would need to apply the projection to each of the items added to the canvas?
Here is the code
Dim objBitMap As Bitmap = New Bitmap(300, 300)
Dim objGeoCanvas As PlatformGeoCanvas = New PlatformGeoCanvas()
Dim colLayers As System.Collections.ObjectModel.Collection(Of SimpleCandidate) = New System.Collections.ObjectModel.Collection(Of SimpleCandidate)()
Dim colLineFeatures As System.Collections.ObjectModel.Collection(Of Feature) = New ObjectModel.Collection(Of Feature)()
Dim colPointFeatures As System.Collections.ObjectModel.Collection(Of Feature) = New ObjectModel.Collection(Of Feature)()
Dim objLine As New LineShape
Dim objVertex As Vertex
Dim objImages As ArrayList = mobjViewer.RouteImageArray
Dim objLatLng As List(Of KeyValuePair(Of String, String)) = mobjViewer.RouteLatLng
Dim strLon As String = ""
Dim strLat As String = ""
Dim strItem As String = ""
If objImages.Count > 0 Then
Session.Item("ImagesPath") = ""
End If
Dim objProjectionJUR As Proj4Projection = New Proj4Projection()
objProjectionJUR.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString
objProjectionJUR.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString
objProjectionJUR.Open()
For i As Integer = 0 To objImages.Count - 1
If i > objLatLng.Count - 1 Then Exit For
Dim strSplit As String() = Split(objLatLng(i).Value.ToString, ",")
If IsNothing(strSplit) = False Then
If strSplit.Count < 2 Then
Else
strLon = strSplit(0)
strLat = strSplit(1)
End If
End If
If Val(strLon) <> 0 And Val(strLat) <> 0 Then
objVertex = objProjectionJUR.ConvertToExternalProjection(CDbl(strLon), CDbl(strLat))
strLon = objVertex.X.ToString
strLat = objVertex.Y.ToString
objLine.Vertices.Add(objVertex)
'ClientScript.RegisterHiddenField("mp" & objLatLng(i).Key.ToString, strLon & "," & strLat)
End If
Next
'Creates the Point Shape
Dim pointMap As New MapShape
For Each objPair As KeyValuePair(Of String, String) In mobjViewer.RouteLatLng
Dim objKey As String = objPair.Key
Dim objValue As String = objPair.Value
If objKey = mstrMPText Then
Dim strLatLng As String() = objValue.Split(CChar(","))
pointMap.Feature = objProjectionJUR.ConvertToExternalProjection(New Feature(CDbl(strLatLng(0).ToString()), CDbl(strLatLng(1).ToString())))
pointMap.ZoomLevels.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(New GeoColor(0, 0, 255), 10, New GeoColor(255, 255, 0), 1)
pointMap.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
Exit For
End If
Next
'Creates the Line Shape
Dim linemap As New MapShape
Dim ext As RectangleShape
With linemap
.Feature = New Feature(objLine)
.ZoomLevels.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Yellow, 4, True)
.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
ext = .Feature.GetBoundingBox
End With
ext.ScaleUp(60)
'Bing Map
' Please set your own information about those parameters below.
Dim applicationID As String = "[Your Bing Key]"
Dim cacheDirectory As String = HttpContext.Current.ApplicationInstance.Server.MapPath("~/App_Data/Bingmaps")
If Directory.Exists(cacheDirectory) = False Then
Directory.CreateDirectory(cacheDirectory)
End If
cacheDirectory = HttpContext.Current.ApplicationInstance.Server.MapPath("~/App_Data/Bingmaps/StreetPix")
If Directory.Exists(cacheDirectory) = False Then
Directory.CreateDirectory(cacheDirectory)
End If
'Begins Drawing the Image
objGeoCanvas.BeginDrawing(objBitMap, ext, GeographyUnit.Meter)
'Builds Bing Maps Layer
Dim objLayer As New BingMapsLayer(applicationID, ThinkGeo.MapSuite.Layers.BingMapsMapType.Road, cacheDirectory)
Dim strKey As String = ""
objLayer.Logo = Nothing
objLayer.Name = "Bing Maps"
objLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException
objLayer.MapType = ThinkGeo.MapSuite.Layers.BingMapsMapType.AerialWithLabels
strKey = objLayer.Name.Replace(" ", "") & "Layer"
objLayer.TileCache = New FileBitmapTileCache(cacheDirectory)
objLayer.Open()
objLayer.Draw(objGeoCanvas, colLayers)
objLayer.Close()
'objGeoCanvas.DrawLine(linemap.Feature, linemap.ZoomLevels.ZoomLevel01.DefaultLineStyle.CenterPen, DrawingLevel.LevelFour)
'Adds the Shapes
'Dim objTempLayer As MapShapeLayer = New MapShapeLayer()
'objTempLayer.MapShapes.Add("Line", linemap)
'objTempLayer.Draw(objGeoCanvas, colLayers)
colPointFeatures.Add(pointMap.Feature)
pointMap.ZoomLevels.ZoomLevel01.DefaultPointStyle.Draw(colPointFeatures, objGeoCanvas, colLayers, colLayers)
colLineFeatures.Add(linemap.Feature)
linemap.ZoomLevels.ZoomLevel01.DefaultLineStyle.Draw(colLineFeatures, objGeoCanvas, colLayers, colLayers)
'objTempLayer = New MapShapeLayer()
'objTempLayer.MapShapes.Add("Point", pointMap)
'objTempLayer.Draw(objGeoCanvas, colLayers)
objGeoCanvas.EndDrawing()
'Adds the border around the image
Dim objBorder As Brush = New SolidBrush(Color.Silver)
Dim objGraphics As Graphics = Graphics.FromImage(CType(objBitMap, Image))
'objGraphics.FillRectangle(objBorder, 0, 0, 6, 6)
objGraphics.DrawLine(New Pen(objBorder, 6), New Point(0, 0), New Point(0, 300))
objGraphics.DrawLine(New Pen(objBorder, 6), New Point(0, 0), New Point(300, 0))
objGraphics.DrawLine(New Pen(objBorder, 6), New Point(300, 0), New Point(300, 300))
objGraphics.DrawLine(New Pen(objBorder, 6), New Point(0, 300), New Point(300, 300))
Dim objPoint As Point = New Point(0, 0)
objGraphics.DrawImage(objBitMap, objPoint)
Return objBitMap
Thanks,
Neil