Community of VE/MapPoint Users and Developers
This is a discussion on Map Objects: I want to display each stations in different color? AnyBody can help me? within the MapPoint 2006/2009 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. ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Map Objects: I want to display each stations in different color? AnyBody can help me? 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 '####################################### |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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 |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| color, display, map, objects, stations |
| ||||
| Posted By | For | Type | Date | |
| Need Consolidation Debt Refinance Info? | This thread | Refback | 03-28-2007 09:27 AM | |
| Pushpin Tool Add-in - MP2K Magazine | This thread | Refback | 11-29-2006 08:53 PM | |
| London McDonald's - MapPoint 2004 Guide - MP2K Magazine | This thread | Refback | 11-28-2006 05:06 AM | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 11-27-2006 04:11 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Display Moving objects on Map in ASP.net | whenry6000 | MapPoint Web Service and Virtual Earth | 2 | 01-17-2007 02:47 PM |
| How to tell if an objects location is visible? | Anonymous | MapPoint 2006/2009 Discussion | 2 | 06-28-2004 09:15 AM |
| limiting objects in collection | Anonymous | MapPoint 2006/2009 Discussion | 0 | 04-27-2004 08:52 AM |
| specify label to all the objects of a layer | Anonymous | Wish List | 0 | 08-28-2002 08:22 AM |
| Mappoint2002 vs. ESRI Map Objects | Anonymous | MapPoint 2006/2009 Discussion | 1 | 08-07-2002 09:15 AM |