TWIAV - Tips & tricks

TWIAV - Tips & tricks

Tools


On this page you will find some MapBasic tools, both the program source and the compiled application. Everything on this page is offered "as is" without warranty of any kind, either expressed or implied, including limitation warranties of merchantability, fitness for a particular purpose, and noninfringement.


MapBasic 9.0 has been used to compile the files - this means that the MBXs offered here will only run with MapInfo Professional 9.0 or higher. If you want to use the tools with another (an older) version of MapInfo Professional, you will have to compile the tool using the relevant version of the Mapbasic compiler.


The following tools are available here:





Mnemonics: Mnemonics for ToolButtons


This little application will give you two menus with menu entries for each of the ToolButtons in the Drawing and Main toolbars in MapInfo Professional.

In the menus mnemonics are used. What is a mnemonic? A mnemonic is an underlined letter in a menu or labeled dialog control that indicates to a user a quick, keyboard method of simulating a click on that element.

This has the advantage that you can use keystrokes to activate a tool: i.e. instead of clicking the Select Button, you can use the keystroke Alt+I+S. And to start to draw a polyline you can use Alt+D+P. With these mnemonics you can enhance your productivity, e.g. when you have to switch very often between Select and Drawing Tools.

The tool has been tested with MapInfo Professional 9.0 and 9.5, and it does not interfere with any of the default mnemonics in the MAPINFOW.MNU. But please be sure to check with any other tools and applications you might be using on top of MapInfo Professional. (If necessary, you can always modify a mnemonic - the source code is provided here.)
Please see the file below for Mnemonics.mb and Mnemonics.MBX:

 Mnemonics.zip

Below you will find the list of keystrokes as defined in this tool:


DRAWINGMAIN
Symbol SymbolAlt+D+S Select SelectAlt+I+S
Line LineAlt+D+L Marquee Select Marquee SelectAlt+I+M
Polyline PolylineAlt+D+P Radius Select Radius SelectAlt+I+R
Arc ArcAlt+D+A Polygon Select Polygon SelectAlt+I+P
Polygon PolygonAlt+D+O Boundary Select Boundary SelectAlt+I+B
Ellipse EllipseAlt+D+E Graph Select Graph SelectAlt+I+G
Rectangle RectangleAlt+D+R Zoom-in Zoom-inAlt+I+Z
Rounded Rectangle Rounded RectangleAlt+D+U Zoom-out Zoom-outAlt+I+O
Text TextAlt+D+T Grabber GrabberAlt+I+A
Frame FrameAlt+D+F Info InfoAlt+I+I
Add Node Add NodeAlt+D+N HotLink HotLinkAlt+I+H
Label LabelAlt+I+L
Drag Map Window Drag Map WindowAlt+I+D
Ruler RulerAlt+I+U

Please note: for zooming and panning in your Map Window default shortcuts are available in MapInfo Professional:


ZOOMING AND PANNING
Zoom-in Zoom-in+Apart from the + and the - and the arrow keys on your keyboard you can also use the mouse wheel for zooming and panning. (To pan: hold down the middle mouse button (the mouse wheel) and move the mouse.)
Zoom-out Zoom-out-
Grabber Grabber←↑↓→




MapInfo2Leaflet


MapInfo2Leaflet MapInfo2LeafletAlt+2+2
With MapInfo2Leaflet you can export a MapInfo table to a web map application using Leaflet - the output consists of an html file, a json file (containing a GeoJSON FeatureCollection) and css files for the styling.

Optionally you can export a thematic layer to color the geometry based on attribute data.

Leaflet is a modern open-source JavaScript library for mobile-friendly interactive maps.

More information about Leaflet can be found here: http://leafletjs.com/

With a few mouse clicks you can export your MapInfo table to a web map application.

Please see the file below for the application and the source code:

 MapInfo2Leaflet32Version036.zip

 MapInfo2Leaflet User Guide.pdf
Export a MapInfo Table to a Web Map Application using Leaflet


Some examples of web map applications created with MapInfo2Leaflet:



This version is compatible with the 'classic' 32 bit version of MapInfo Professional, 9.5 or higher (because it uses some .NET capabilities)




MapSearch


MapSearch MapSearchAlt+Q+E+E
The MapSearch function allows you to search for objects in the current Map window, based on values in a given column in a table (e.g. a municipality by it's name).

MapSearch offers functionality comparable to the existing Find function in MapInfo Professional.

First you will need to specify (or respecify) the table and column to search.
Then a dialog will appear where you can enter a value (e.g. a part of the municipality name).
The list with possible results will be updated while you type.
After selecting a value and clicking OK the object(s) found will be highlighted (selected) and the Map window will zoom in to them.

The MapSearch button and the MapSearch menu item (in the Query menu) will only be enabled when the front window is a map window.

Please see the file below for the application (MapSearch.MBX, MSearch.dll and MSearchDialog.dll) and the source code (MapSearch.MB and MSearchDialog.cs):

 MapSearch.zip
MapSearch Dialog


This application is compatible with MapInfo Professional 9.5 and higher (because it uses some .NET capabilities)

The C# source code is included. You can compile the file using the Visual C# 2008 Compiler:

csc /t:library MSearchDialog.cs

(No Visual Studio needed :-)





Mask


Mask MaskAlt+M+K+K
The Mask application allows you to create a translucent mask around one or more region objects.

Select one or more region objects - either by clicking in the map window or by using a query.

The Mask button and the Mask menu item (in the Map menu) will only be enabled in the following circumstances:

  • The selecion only contains region objects
  • The front window is a map window

A dialog appears, allowing you to:

  • Set the border style
  • Set the level of translucency (0-100%)
  • Set the folder and the name of the resulting mask table


Please see the file below for Mask.MB, Mask.MBX and Mask.dll:

 Mask.zip
Mask around Utrecht Province (showing Bing Aerial)

Mask Dialog

This application is compatible with MapInfo Professional 9.5 and higher

(The support of vector translucency has been introduced in MapBasic 9.5)





Query Date and Time


The tool Query Date and Time (QDateTime.MBX) will add 2 functions to the Query menu:


Select by Date Select by DateAlt+Q+T+S
The function 'Select by Date' offers a dialog to select records by date: before, after or between certain dates (as stored in a Date or DateTime column).

If querying a DateTime column the time can also be taken into consideration.

Select by Date

Select using Date Functions
Select using Date Functions Select using Date FunctionsAlt+Q+T+T

The function 'Select using Date Functions' offers a dialog to query Date and/or DateTime columns using the following functions:

  • Day(): days within a month (1-31)
  • Weekday(): days within a week (Sun-Sat)
  • Month(): months (Jan-Dec)
  • Year(): years


The syntax of the resulting queries will be printed to the Message window, e.g.:

Select * From Calendar Where Date >= "20120828" AND Date <= "20130218" into Last_changes

Select * From Calendar Where Day(Date) in (29) And Month(Date) in (2) into Leap_days


The tool can be found in the zip file below.


To be able to run the tool in MapInfo Professional you will need these 3 files: QDateTime.MBX, MBExtensions.dll and DTIcons.dll.



The source code of the tool is also included in the zip file: MBExtensions.cs, QDateFunctions.mb, QDates.mb, QDateTime.def, QDateTime.mbp, QDateTimeShared.mb and QDateTimeUI.mb



 QDateTime.zip



After running the tool the function appears in MapInfo Professional under Query>Query Date and Time


This tool will only run on MapInfo Professional 9.5 and higher (because it uses some .NET capabilities)


Background information on the C# methods used in this tool can be found here




Reverse Geocoding


Reverse Geocoding Reverse Geocoding
This little tool - called Omen.MBX - provides some Reverse Geocoding functionality for MapInfo Professional.

By activating the tool Reverse Geocoding you can lookup an address by clicking in the Map Window, regardless of any open tables.

The results are stored in the the table ReverseGeocoding.TAB. (This table will be created automatically.)

The address is obtained via a request to Nominatim: http://nominatim.openstreetmap.org


This sample request will retrieve the details of the Centre Pompidou in Paris.

Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright

A .Net Assembly is being used to process the Nominatim request. The source code - both MapBasic (*.mb) and C# (*.cs) - is included in the download file.

Please see the file below for Omen.mb, Omen.MBX, Omen.dll, OSMNominatim.cs and OSMNominatim.dll:

 Omen.zip
The results are stored in the the table ReverseGeocoding.TAB




File > Save Table As...


Save Table As Save Table AsAlt+F+E

This application adds a 'Save Table As...' option to MapInfo Professional.

This option is accessible via the File (and the Tools) menu, the Standard toolbar and the Table List context menu.

'Save Table As' allows you to save a table with a new name (and location). After saving the new table, the original table will be closed and the new table will be opened.

Please see the file below for FileSaveAs.mb, FileSaveAs.MBX and FileSaveAs.dll:

 FileSaveAs.zip
Save Table As in Table List Context Menu




Sort


With Sort you can sort your MapInfo table by up to 3 columns, in ascending or descending order. You can choose to display the query results in a Browser window or to save the sorted table by overwriting the existing table. And there is an option to show the syntax of the SQL statement in a Message window.

There are more sorting tools to be found on the net. This is my version;-)
Please see the file below for Sort.MB, Sort.MBX and Sort.dll:

 Sort.zip





ZoomButtons


This tool does not do anything special. It just adds a Toolbar with buttons for 2 already existing functions: VIEW ENTIRE LAYER and PREVIOUS VIEW.

This example is mainly offered to show how to add custom icons to your own MapBasic application. The icons used are stored in a Dynamic Link Library: ZoomButtons.dll. This DLL has been created with Pelles C (Version 5).

If you want to know more about adding custom icons to your own MapBasic app, please have a look here.
Please see the file below for ZoomButtons.mb, ZoomButtons.MBX and ZoomButtons.dll:

 ZoomButtons.zip




More tools will follow...;-)



What do you think of these tools? If you have any , please let me know.