PDA

View Full Version : two 'axMappointControl' in a form?



laurent572
08-15-2011, 04:15 PM
Hello, I program with Visual Basic 2008 and I want to display two different cards in one window with 'AxMappointControl1' and 'AxMappointControl2'
I made this code, but it does not work, my card still appears in the 'AxMappointControl1' and the 'AxMappointControl2' is the map of Europe, why?


Public Class Form1
Public iMap As MapPoint.Map
Public rMap As MapPoint.Map

Sub AddWaypoints()
iMap = AxMappointControl1.ActiveMap
Dim oRte As MapPoint.Route
iMap = GetObject(, "MapPoint.Application").ActiveMap
iMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner

oRte = iMap.ActiveRoute
oRte.Clear()

With oRte.Waypoints
.Add(iMap.FindAddressResults("rue jean jaures", "HAYANGE", , , , )(1))
.Add(iMap.FindAddressResults("rue de la victoire", "KNUTANGE", , , , )(1))
End With
oRte.Calculate()
oRte.Application.ItineraryVisible = False
oRte.Application.PaneState = MapPoint.GeoPaneState.geoPaneNone
'Zoom to the route
oRte.Directions.Location.GoTo()

End Sub

Sub adresse()
rMap = AxMappointControl2.ActiveMap
Dim oFindResults As MapPoint.FindResults
Dim oLocation1 As MapPoint.Location
Dim oPushPin1 As MapPoint.Pushpin
rMap = GetObject(, "MapPoint.Application").ActiveMap

rMap.MapStyle = MapPoint.GeoMapStyle.geoMapStyleRoad
oFindResults = rMap.FindAddressResults("49 rue de la victoire", "KNUTANGE", , , , MapPoint.GeoCountry.geoCountryFrance) '.Item(1)
oLocation1 = oFindResults(1)
oLocation1.GoTo()
oPushPin1 = rMap.AddPushpin(AtLocation:=oLocation1, Name:="Intervention")
oPushPin1.BalloonState = MapPoint.GeoBalloonState.geoDisplayBalloon


End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AxMappointControl1.NewMap(2)
AxMappointControl2.NewMap(2)
AddWaypoints()
adresse()
End Sub

Eric Frost
08-15-2011, 04:59 PM
GetObject is kind of funky, it doesn't really work well or at all with multiple instances.

There might be some Windows API stuff (ninja business :shuriken:) you can use?

Just glancing through there again, why are you using GetObject at all anyway? I don't think you need it.

Eric

laurent572
08-15-2011, 05:03 PM
How i do ?

Eric Frost
08-15-2011, 05:31 PM
Well, you've already done --


iMap = AxMappointControl1.ActiveMap

So unless I'm mis-understanding something, I don't think you have to do --


iMap = GetObject(, "MapPoint.Application").ActiveMap


That's just my first impression, hope that helps!

Eric