Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
You'll need to expand a bit on this - what exactly do you mean by "the image" – Stev_k Nov 27 '11 at 23:18
My task is to replace standart icon of the point object by the image or symbol. – aifabrEgAz Nov 28 '11 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 Dec 7 '11 at 10:43
up vote 1 down vote accepted

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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