I'm attempting to make a map renderer inside a PictureBox with VB.NET. I'm trying to convert a map (with Mercator) projection when given a Longitude and Latitude value and a zoomed factor would convert it to a pixel point location.
I've found several examples of converting a Mercator projection-based map's longitude and latitude but they either are using a world map (I'm using a specific area of that map) or don't account or use a different type of Scale Factor.
My map rendering application takes a SVG and loads it with the SVG-NET library as a bitmap into a PictureBox with a variable that contains a Zoom Factor.
I'm trying to write a function that when given the zoom factor, longitude, and latitude will output the relative location of that point inside a PictureBox.
This is the code I use to render the SVG into the PictureBox.
Dim SF As String = 1 'Zoom/Scale Factor
'Use Scrollbar to Zoom PictureBox2 which contains the loaded bitmap
Private Sub PictureBox2_MouseWheel(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseWheel
If e.Delta > 0 Then
SF = SF + 0.1
Dim svgDocument = Svg.SvgDocument.Open("C:\users\admin\Pictures\doc.svg")
svgDocument.ShapeRendering = SvgShapeRendering.Auto
PictureBox2.Size = New Size(CInt(650 * SF), CInt(700 * SF))
Dim bmp As Bitmap = svgDocument.Draw(PictureBox2.Size.Width, PictureBox2.Size.Height)
PictureBox2.Image = bmp
Else
SF = SF - 0.1
Dim svgDocument = Svg.SvgDocument.Open("C:\users\admin\Pictures\doc.svg")
svgDocument.ShapeRendering = SvgShapeRendering.Auto
PictureBox2.Size = New Size(CInt(650 * SF), CInt(700 * SF))
Dim bmp As Bitmap = svgDocument.Draw(PictureBox2.Size.Width, PictureBox2.Size.Height)
PictureBox2.Image = bmp
End If
End Sub
I know that the SVG's default width is 450 and the height is 530. I also know that the left longitude is "123.658963" and the top latitude is "45.523885" and the right longitude is "145.820743" and the bottom latitude is "24.217586".
How can I write a function for this?
The SVG can be downloaded from here: Google Drive Link
