3

I need to change the image of the objects which are in the Selection Table using MapBasic functions. When I say "Image" I mean point object icon on the map.

asked Nov 27, 2011 at 16:59
3
  • You'll need to expand a bit on this - what exactly do you mean by "the image" Commented Nov 27, 2011 at 23:18
  • My task is to replace standart icon of the point object by the image or symbol. Commented Nov 28, 2011 at 11:21
  • Are you trying to replace them with a custom image that you have made? Do you want to end up with them all the same or are you trying to change individual points? Commented Dec 7, 2011 at 10:43

1 Answer 1

2

Not exactly full of best practice but this code should change the current selection to an image of a fire hydrant. Just set NewSymbol to what ever you want to display. You may want to use MakeSymbol instead of MakeCustomSumbol if by "image" you meant a font symbol rather than an image symbol.

Include "mapbasic.def"
Declare Sub Main
Sub Main
Dim RowNumber as integer
Dim NewObject as object
Dim XCoord as float
Dim YCoord as float
Dim NewSymbol as symbol
' Note no protection to ensure if you have a selection.
' Change this to be the desired symbol. Must be in MapInfo custom symbol folder. Use MakeSymbol for other symbols.
NewSymbol = MakeCustomSymbol("FIRE2-64.BMP", BLUE, 64, 0)
' set the coordinate system to be the same as the table.
run command "set map "+ tableinfo(selection, tab_info_coordsys_clause)
'Loop over rows in selection
For RowNumber = 1 To SelectionInfo(sel_info_nrows)
 ' Get a row
 fetch rec rownumber from selection
 ' Update point to be new symbol
 XCoord = ObjectGeography(selection.obj, obj_geo_pointx)
 YCoord = ObjectGeography(selection.obj, obj_geo_pointy)
 Create Point Into Variable NewObject (XCoord, YCoord) Symbol NewSymbol
 ' Update row
 Update Selection Set obj = newobject where RowID = RowNumber 
next
End Sub
answered Jan 30, 2012 at 9:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.