2

the question is rather simple, but what I am working on is not..
this is a marker from a control called GMaps.NET enter image description here

the next picture is a form, that follows the marker when I drag the map, something like the InfoWindow on google maps API.
only problem is that, it covers the marker, and I can't offset it no matter how hard I think.enter image description here

this is my current code..

Private Sub map_OnMapDrag() Handles map.OnMapDrag        
    Form2.Show()
    Form2.Location = camera1.LocalPosition 
End Sub

please list some ways on how I can offset it so we can see the marker.. thanks!

Reminder : you can't directly use camera1.LocalPosition's Point because its coordinates are inside the map. whilst Form2.Location is on the form. though the same value, they are worlds apart :)
so give different options that I can try TIA

6
  • 3
    Can you not just create a new point that is camera1.LocalPosition plus some arbitrary amount? I thought point was a struct anyway so adding another Point to it will result in another instance (msdn.microsoft.com/en-us/library/…) so can you not use camera1.LocalPosition + new Point(10,10) or something similar?
    – Charleh
    Nov 28, 2013 at 9:30
  • I don't get you, but if I create another Point the form's location will be on that point and then it cannot be dragged along with the marker.
    – AdorableVB
    Nov 28, 2013 at 9:32
  • good thing I asked. I am pretty sure that I used that equation a while ago.. wonder why it gave an error. thanks! @Charleh
    – AdorableVB
    Nov 28, 2013 at 9:33
  • OnMapDrag is called multiple times as you drag the map. Point is a struct and when assigning it you are making a copy of the values - it's a value type not a reference type. Form2.Location does not point at the instance held in camera1.LocalPosition as value types do not have reference semantics. You are simply copying the values every time the map updates whilst dragging it (this may be 1 update or it may be 1000 updates!). I'd have a look at "value types vs reference types"
    – Charleh
    Nov 28, 2013 at 9:34
  • Here: albahari.com/valuevsreftypes.aspx - this one actually talks about Form and the Point struct so it's almost exactly what you need to read. Worth reading anyway! Particularly the lines following the sentence "If we copy the objects to new variables:"
    – Charleh
    Nov 28, 2013 at 9:37

1 Answer 1

0

Try out Form2.Location.Offset(dx, dy)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.