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.

  • You'll need to expand a bit on this - what exactly do you mean by "the image"
    – Stev_k
    Commented Nov 27, 2011 at 23:18
  • My task is to replace standart icon of the point object by the image or symbol.
    – aifabrEgAz
    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?
    – Mr_Chimp
    Commented Dec 7, 2011 at 10:43

1 Answer 1


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    

End Sub

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.