Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 4 of 4

Map Objects: I want to display each stations in different color? AnyBody can help me?

This is a discussion on Map Objects: I want to display each stations in different color? AnyBody can help me? within the MapPoint Desktop Discussion forums, part of the Map Forums category; I am using MO 2.2 version. My problem is : I have a shape file with 5 points(Stations) on it. ...

  1. #1
    sirajudeen507 is offline Junior Member White Belt
    Join Date
    Nov 2006
    Posts
    2

    Map Objects: I want to display each stations in different color? AnyBody can help me?

    I am using MO 2.2 version.
    My problem is :
    I have a shape file with 5 points(Stations) on it. Say this is 'Air Quailty Monitoring' stations. Based on the
    quality of air, each station must be displayed in different color. That means if stations A's air quality is good,
    that station must be displayed in green color. If station B's air quality is not good then its color is yellow, it
    stations C's air quality is very bad its color will be in red. (color change is based on quality of air)
    when application opens all the staion's color is Maroon. I have written code for automatically checking the Air
    Quality of each stations. I tried several ways, its color is changing to green, yellow or red, but when the control
    goes from one station to another station the first stations's color became default color(Maroon), not green,
    yellow or red. That is, when the control comes to "AfterTrackingLayerDraw" each time the previous stations color
    become Maroon(defalt) color.
    (Note: I am taking X and Y coordinates from database. Not from the map when we click on it)
    '#######################################
    'this is the function
    Private Sub MapMain_AfterTrackingLayerDraw(ByVal hdc As stdole.OLE_HANDLE)
    If flg_DispLocInDiffClr = "y" Then 'flg_DispLocInDiffClr is global variable(flag)
    Dim ge As MapObjects2.GeoEvent
    Dim ptsTemp As New MapObjects2.Points
    Dim pt As MapObjects2.Point
    Dim pts As MapObjects2.Points
    Dim ploc As New MapObjects2.PlaceLocator
    Set g_symSelection = New MapObjects2.Symbol
    Set pt = New MapObjects2.Point
    pt.x = LocX 'LocX is global variable
    pt.y = LocY 'LocY is global variable

    Dim strExpression As String
    'arrValue_StationNames is an array for storing station name and its X, Y coordinaes, GoThruStn is a global
    variable
    If AAQMS_Mainfrm.MapMain.Layers(0).Records.Fields("Lo cation").Type = moString Then
    strExpression = "Location='" & arrValue_StationNames(GoThruStn, 0) & "'"
    End If
    ' Perform the Search.
    Dim recSelection As MapObjects2.Recordset
    Set recSelection = MapMain.Layers(0).SearchExpression(strExpression)
    ' If we have found features, draw them in Yellow.
    If Not recSelection.EOF Then
    With g_symSelection
    .SymbolType = MapMain.Layers(0).Symbol.SymbolType
    .Color = Adjust_Loc_Color(arrValue_LastRecordOnly(PassValue C, 1))
    .Size = MapMain.Layers(0).Symbol.Size
    .Style = moCircleMarker
    End With

    ' MapMain.FlashShape CurLoc, 2 ' this is working - flasing 2 times
    MapMain.DrawShape recSelection, g_symSelection
    ' Set pts = ploc.Locate(arrValue_StationNames(GoThruStn, 0))
    ' MapMain.DrawShape pts, g_symSelection
    ' Set ge = MapMain.TrackingLayer.AddEvent(pt, 0)

    End If
    ' Set recSelection = Nothing
    End If
    End Sub
    '#######################################
    My problem is after scanning the first station (Station 'A') we can see the color of station A keeps changing to
    green or red or yellow(based on some calculation-air quality) but when the control goes to next station 'B' its
    color will be changed to green or yellow or red but stations A (Previous one)became Maroon(default) color. I want to keep the
    color of station A in green or red or yellow(based on the quality of station) while scaning the other stations.
    Each stations are flasing in yellow or green or red(based on the air quality) but it is not keeping the the color.
    I want to display each stations in different color.....Any way can be used...by puting graphics or add geo events or any how I want to display that station in different color...Any one can help Please?



    '#######################################
    'Automatic scanning starts from this module
    '#######################################
    Sub FirstCtrlInThisModule()
    Dim myStation As String
    Dim RecSet1 As MapObjects2.Recordset
    defArrowPtr = "y"
    ReDim arrValue_StationNames(0 To (RecSet1.Count - 1), 0 To 2)

    For GoThruStn = 0 To UBound(arrValue_StationNames)
    arrValue_StationNames(GoThruStn, 0) = RecSet1.Fields.Item("Location")
    arrValue_StationNames(GoThruStn, 1) = RecSet1.Fields.Item("Nothing")
    arrValue_StationNames(GoThruStn, 2) = RecSet1.Fields.Item("Easting")
    RecSet1.MoveNext
    Next GoThruStn
    For GoThruStn = 0 To UBound(arrValue_StationNames)
    Set RecSet = RecSet1

    LocX = arrValue_StationNames(GoThruStn, 1)
    LocY = arrValue_StationNames(GoThruStn, 2)
    Call mod_Scaning.ScanAllStations(CStr(arrValue_StationN ames(GoThruStn, 0)))
    Next GoThruStn
    defArrowPtr = "n"
    End Sub
    '#######################################
    'Each station's 1, 8 & 24 hours data is monitoring
    '#######################################
    Sub ScanAllStations(CurStation As String)
    Call ScanValue(1, CurStation)'scan 1 hour data
    Call ScanValue(8, CurStation)'scan 8 hour data
    Call ScanValue(24, CurStation)'scan 24 hour data
    End Sub
    '#######################################
    Sub ScanValue(MyHr As Integer, CurStation1 As String)
    Dim c
    Dim MycurRecSet As New ADODB.Recordset
    Dim myStation As String
    myStation = MyDataCollectSP.Get_Station_Id(CurStation1)
    Set MycurRecSet = MyDataCollectSP.CollectReading_FroToDate(myStation , CStr(Date), CStr(Date), MyHr) 'this is stored procedure - MS SQL server

    Call Mod_Functions.set_array_Size(MyHr) 'call this fn for setting array size - dynamicaly resize the array

    For c = 0 To (MycurRecSet.Fields.Count - 1)
    arrValue_LastRecordOnly(c, 0) = MycurRecSet.Fields(c).Name
    ' arrValue_LastRecordOnly(c, 1) = MycurRecSet.Fields(c).Value
    Next c
    Do While Not MycurRecSet.EOF
    For c = 0 To (MycurRecSet.Fields.Count - 1)
    arrValue_LastRecordOnly(c, 1) = MycurRecSet.Fields(c).Value
    Next c
    MycurRecSet.MoveNext
    Loop
    For c = 0 To UBound(arrValue_LastRecordOnly, 1)
    If Not IsEmpty(arrValue_LastRecordOnly(c, 1)) Then

    PassValueC = c
    flg_DispLocInDiffClr = "y"
    AAQMS_Mainfrm.MapMain.TrackingLayer.Refresh True
    flg_DispLocInDiffClr = "n"
    End If
    Next c
    End Sub
    '#######################################
    'Station's color is based on this fuuction
    '#######################################
    Function Adjust_Loc_Color(ParaVal1)
    Static PrevParaVal1
    Static prevClr
    If PrevParaVal1 > ParaVal1 Then
    Adjust_Loc_Color = prevClr
    Exit Function
    End If
    If ParaVal1 >= 0 And ParaVal1 <= 25 Then
    prevClr = moGreen
    ElseIf ParaVal1 > 25 And ParaVal1 <= 50 Then
    prevClr = moYellow
    ElseIf ParaVal1 > 50 And ParaVal1 <= 75 Then
    prevClr = moOrange
    ElseIf ParaVal1 > 75 And ParaVal1 <= 100 Then
    prevClr = moPurple
    ElseIf ParaVal1 > 100 Then
    prevClr = moRed
    End If

    PrevParaVal1 = ParaVal1
    Adjust_Loc_Color = prevClr

    End Function
    '#######################################

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Map Objects: I want to display each stations in different color? AnyBody can help

    Hi,

    You can put pushpin on each station, and change his symbol in function of the air quality. Lots of color are available, and you can also add your own bitmaps to it.

  3. #3
    sirajudeen507 is offline Junior Member White Belt
    Join Date
    Nov 2006
    Posts
    2

    Re: Map Objects: I want to display each stations in different color? AnyBody can help

    Thank you very much for your response Mr. BlackBelt.
    Can u write some code using pushpin, so I can understand easily How to use it...Remember I am using Mapobjects and version is 2.2
    I didn't get any help file related to pushpin....
    Once again thanku and expecting ur reply.

    Siraj

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Map Objects: I want to display each stations in different color? AnyBody can help

    Hi,

    Sorry I have read your message to fast. This forum is for Microsoft Mappoint only. BTW: I cannot help because I never used MapObjects, sorry.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Display Moving objects on Map in ASP.net
    By whenry6000 in forum Bing Maps and MapPoint Web Service
    Replies: 2
    Last Post: 01-17-2007, 02:47 PM
  2. How to tell if an objects location is visible?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 06-28-2004, 09:15 AM
  3. limiting objects in collection
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-27-2004, 08:52 AM
  4. specify label to all the objects of a layer
    By Anonymous in forum Wish List
    Replies: 0
    Last Post: 08-28-2002, 08:22 AM
  5. Mappoint2002 vs. ESRI Map Objects
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-07-2002, 09:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96