Drawing a map


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Drawing a map

  1. #1
    Join Date
    Jan 2006
    Posts
    3

    Drawing a map

    Hi

    I am trying to draw a map in a picturebox. First I load the base image which is a 1024x1024 bitmap of the map (no annotations) from Private Sub draw_map(), then to add all the map synbols, the data is collected from a simple text file, analysed and then drawn over the base map using x y coordinates. This is called from Private Sub draw_objects()

    So when the form containing the picturebox loads it runs
    Code:
            draw_map()
            draw_objects()
    The strange thing is that all the objects are drawn first, then the map, over the objects (or the objects disappear again, I don't know). I tried doing it from the form_Paint but that only results in the symbols reloading endlessly and flashing on the screen.

    I'm thinkig of going back to VB6

    I am so new to this so be gentle

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Please post a sample of your code from the draw_objects function. Are you sure you're drawing the objects on the picturebox and not on the form?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jan 2006
    Posts
    3
    Quote Originally Posted by Phil Weber
    Please post a sample of your code from the draw_objects function. Are you sure you're drawing the objects on the picturebox and not on the form?
    Thanks for replying Phil, I will try to provide som code here (the pictureBox is names picChart) :

    Code:
    Private Sub draw_map()
    
       Dim vsImage As Image
    
       vsImage = System.Drawing.Image.FromFile(vsPath & "simple.bmp")
    
       picChart.Image = vsImage
    
    End Sub
    So far so good, this displays as it should. Then to load the map symbols it uses

    Code:
    Private Sub draw_objects()
    
       Dim drawSymbol As System.Drawing.Graphics
       drawSymbol = picChart.CreateGraphics
    
       objImage = System.Drawing.Image.FromFile("C:\bla bla bla\images\buoy.gif")
    
       drawSymbol.DrawImage(objImage, xCoord - 5, yCoord - 5, 10, 10)
    
    End Sub
    This is only a part of the code where it draws the buoy.gif onto the map.
    (The xCoord and yCoord are calculated from Latitude/Longitude values in the objects.txt file)

    Then the final part is

    Code:
    Private Sub picChart_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picChart.Paint
        draw_map()
        draw_objects()
    End Sub
    My understanding is that using the _Paint will replace the AutoRedraw previosly used in VB6.

    I've also tried running the draw_map and draw_object on the form Load but that will only show the objects loading once and then clear them. At least this way keeps them flashing on the screen so I can see them

    Please let me know if you need any more code, I'm not really sure what I should be showing here.

Similar Threads

  1. Replies: 3
    Last Post: 01-28-2006, 08:25 AM
  2. map functions help
    By pouncer in forum C++
    Replies: 5
    Last Post: 01-26-2006, 02:25 AM
  3. Map 2 strings
    By drkybelk in forum VB Classic
    Replies: 2
    Last Post: 09-15-2005, 12:06 PM
  4. Looking for a good site map tool
    By Woody Medina in forum Architecture and Design
    Replies: 4
    Last Post: 08-01-2001, 08:40 AM
  5. map areas not passing Form object to java script
    By mark hembree in forum ASP.NET
    Replies: 1
    Last Post: 01-11-2001, 11:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center