Link to home
Start Free TrialLog in
Avatar of LD147
LD147Flag for United States of America

asked on

MapPoint pushpins not showing on map

For some reason, my pushpins are not showing in my VB 2008 application.  When I use just the 3 columns as shown in this URL (http://www.mapforums.com/sitemap/t-11197.html) and use a simple dummy file with just "lat", "long", and "name", it works fine.  As you can see from the code, I have expanded this to accomodate more data, but now nothing shows on the map.  TIA.

Also, the bit at the end where it's supposed to center on a pin isn't working. I know for sure there is an entry by that name in the CSV.

The .csv file and the .rpt file are being created perfectly, but does it matter in which order the fields are organized in the csv?  Looking at the code, I didn't think it did.
Dim objDataSets As MapPoint.DataSets
        Dim objDataSet As MapPoint.DataSet
        Dim zDataSource As String

        Dim myLong As String
        Dim myLat As String
        Dim myName As String
        Dim myMeterID As String
        Dim myIntDate As String
        Dim myIntTime As String
        Dim mysignal As String
        Dim mygatewayID As String
        Dim mys2 As String

        Dim location As MapPoint.Location
        Dim pushpin As MapPoint.Pushpin
        Dim centreMap As MapPoint.Pushpin
        Dim xFieldArray(0 To 8, 0 To 1) As Object

        'Use the lat field as the Latitude
        xFieldArray(0, 0) = "lat"
        xFieldArray(0, 1) = MapPoint.GeoFieldType.geoFieldLatitude
        'Use the long field as Longitude
        xFieldArray(1, 0) = "long"
        xFieldArray(1, 1) = MapPoint.GeoFieldType.geoFieldLongitude
        'Use the name field as the Name
        xFieldArray(2, 0) = "name"
        xFieldArray(2, 1) = MapPoint.GeoFieldType.geoFieldName

        xFieldArray(3, 0) = "MeterID"
        xFieldArray(3, 1) = MapPoint.GeoFieldType.geoFieldData

        xFieldArray(4, 0) = "IntDate"
        xFieldArray(4, 1) = MapPoint.GeoFieldType.geoFieldData

        xFieldArray(5, 0) = "IntTime"
        xFieldArray(5, 1) = MapPoint.GeoFieldType.geoFieldData

        xFieldArray(6, 0) = "signal"
        xFieldArray(6, 1) = MapPoint.GeoFieldType.geoFieldData

        xFieldArray(7, 0) = "GatewayID"
        xFieldArray(7, 1) = MapPoint.GeoFieldType.geoFieldData

        xFieldArray(8, 0) = "s2"
        xFieldArray(8, 1) = MapPoint.GeoFieldType.geoFieldData

        zDataSource = "C:\gatewaydata\myData.csv" 'this is our data file
        objDataSets = FrmMain.AxMappointControl2.ActiveMap.DataSets
        objDataSet = objDataSets.LinkData(zDataSource, "name", xFieldArray, MapPoint.GeoCountry.geoCountryUnitedStates, MapPoint.GeoDelimiter.geoDelimiterComma) 'links to the data file rather then imports it 

        'now loop through each data element, assign it to a variable and use the variable to plat a pushpin position
        For Each objField In objDataSet.Fields
            myLong = objDataSet.Fields("long").Value 'this is my longitude
            myLat = objDataSet.Fields("lat").Value 'this is my latitude
            myName = objDataSet.Fields("name").Value ' name of the position
            myMeterID = objDataSet.Fields("MeterID").Value
            myIntDate = objDataSet.Fields("IntDate").Value
            myIntTime = objDataSet.Fields("IntTime").Value
            mysignal = objDataSet.Fields("signal").Value
            mygatewayID = objDataSet.Fields("GatewayID").Value
            mys2 = objDataSet.Fields("s2").Value

            location = FrmMain.AxMappointControl2.ActiveMap.GetLocation(myLong, myLat) 'plot the position
            pushpin = FrmMain.AxMappointControl2.ActiveMap.AddPushpin(location, myName) 'add a pushpin to that position
            pushpin.BalloonState = 2 'set the balloon display WHEN THE PUSHPIN IS CLICKED
            pushpin.Symbol = 0 'set the pushpin symbol
        Next objField

        'when all the positions are plotted, line up on one of the pins
        centreMap = FrmMain.AxMappointControl2.ActiveMap.FindPushpin("David Jones")
        centreMap.GoTo()

        'zoom into the display
        FrmMain.AxMappointControl2.ActiveMap.ZoomIn()

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of LD147
LD147
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial