Adding coordinates to layout

1,031 views
Skip to first unread message

mark909

unread,
Feb 1, 2011, 12:02:41 PM2/1/11
to MapInfo-L
Hello I was hoping to add coordinates to the layout map. Something
along the lines of....


456000 457000 458000 459000


466000


476000


486000

around the dataframe.

Any ideas?

Thanks for your help!

Peter Horsbøll Møller

unread,
Feb 1, 2011, 12:54:37 PM2/1/11
to mapi...@googlegroups.com
If you happen to have either Encom Discover or Encom Engage, that could solve this easily

Peter Horsbøll Møller
Pitney Bowes Business Insight - MapInfo


2011/2/1 mark909 <markb...@yahoo.co.uk>
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

Greg Driver

unread,
Feb 1, 2011, 1:23:22 PM2/1/11
to MapInfo-L
There's a tool called Graticule that will build a grid in the map
window and label it with coordinates, which can then be seen in the
layout window -

http://tinyurl.com/6yx6lhl

Or, you could try this tool - "Will Create a Coordinate grid on the
selected frame in a layout window" - though I've not tried it:

http://tinyurl.com/655fzk3

HTH

Greg.

mark909

unread,
Feb 2, 2011, 11:39:58 AM2/2/11
to MapInfo-L
Cool thanks for your help greg!
> > Thanks for your help!- Hide quoted text -
>
> - Show quoted text -

Nesh P.

unread,
Feb 27, 2014, 6:45:32 PM2/27/14
to mapi...@googlegroups.com
Is anyone willing to give me an example of  how to do this in MapBasic ?

I would like to create real coordinates from map window in layout. Something like this:


Thanks

DawnH

unread,
Feb 28, 2014, 12:23:27 AM2/28/14
to mapi...@googlegroups.com
There is another tool called Gratic.mbx uploaded originally by Steve Wallace and Jacques Paris - which draws tick marks along the map boundary and labels them with the projection coordinates.  I wouldn't be without it - ever!   You can download it from here: http://georezo.net/jparis/decharge_liste_mbx.htm or here: http://www.mapinfotools.com/index.php?option=com_sobi2&sobi2Task=sobi2Details&catid=0&sobi2Id=273&Itemid=72

Dawn Hendrick
Hobart Tasmania
Australia

Nesh P.

unread,
Feb 28, 2014, 3:35:53 AM2/28/14
to mapi...@googlegroups.com
Thank You Dawn. But, I am more interested in how to accomplish that with MapBasic.

Lars I. Nielsen

unread,
Feb 28, 2014, 5:26:52 AM2/28/14
to mapi...@googlegroups.com

Hi Nesh,

 

The layout is accessed as a table with just the OBJ column. Same as the cosmetic layer in a mapper window.

 

A layout is basically just a mapper with only a cosmetic layer, and the name of the "cosmetic table" is retrieved via the WindowInfo(win_id,WIN_INFO_TABLE) function.

 

Then it's just a question of issuing a number of Create Text statements (or other object types) to populate the table / layout window.

 

One gotcha is forgetting to set Set Layout Units to whatever unit value you're using.

 

Another gotcha is the coordsys, which has (0,0) in the upper-left corner, with Y increasing downwards.

 

 

Kind regards / Med venlig hilsen
Lars I. Nielsen
----------------------------
------------------------------------

Landinspektør, Senior GIS Programmør og Konsulent
Hvenegaard Landinspektører A/S
Rugaardsvej 55, DK-5000 Odense C
Denmark
Tel. +45 6313 5050
http://www.hvenegaard.dk

--

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
 

---

You received this message because you are subscribed to the Google Groups "MapInfo-L" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Nesh P.

unread,
Feb 28, 2014, 7:20:50 AM2/28/14
to mapi...@googlegroups.com
Thanks for advice Lars, I would try to do it over the weekend.
If I stuck, i will post whats the problem here :)

Nesh P.

unread,
Mar 6, 2014, 5:00:44 AM3/6/14
to mapi...@googlegroups.com

I did it. 
...and if some of you guru/experts read this, please be gentle with critics:)


------------------------------------------------------------------------
Include "MAPBASIC.DEF"
Include "ICONS.DEF"
Include "MENU.DEF"

Type Points
x As Float
y As Float
End Type

Declare sub main

Sub Main

dim iMapWindowID as Integer
dim iLayoutWindowID as Integer

dim sPrinterName as String

dim s_Paper as string
dim s_Orient as string
dim i_Paper as smallint

dim mar, h_Pap, h_Pap2, w_Pap, w_MapFrame, h_MapFrame, w_Table, h_Table, w_Logo as Float
dim pT, f1, f2, f3, f4, t1, t2, t3, t4 as Points

dim centerX, centerY, mapZoom, mapScale, minX, maxX, minY, maxY, dX, dY, LmaxY, LminY as Float
dim a, b, b1, b2, Yp, Rcm, R as Float

'==============================================================
' Basic setup

Set Format Number "9,999.9"
print MapperInfo(FrontWindow(),MAPPER_INFO_COORDSYS_CLAUSE_WITH_BOUNDS)
Set Distance Units "m"
Set Paper Units "cm"

sPrinterName = WindowInfo(FrontWindow(),WIN_INFO_PRINTER_NAME)
print sPrinterName

' - Paper format
s_Paper = "A4"
s_Orient = "Landscape"
' - Papersize.def value
i_Paper = 9
' - dimension of paper
h_Pap=21
w_Pap=29.7
' - margine in cm
mar = 0.6
' - Coordinates of starting point in layout
pT.x = 1
pT.y = 1
' - height of custom table area
h_Table=1.7
w_Table = w_Pap-2*pT.x
h_MapFrame = h_Pap-2*pT.y-h_Table
w_MapFrame = w_Pap-2*pT.x
w_Logo = h_Table*2.25
iMapWindowID = WindowID(FrontWindow())
minX = MapperInfo(FrontWindow(),MAPPER_INFO_MINX)
maxX = MapperInfo(FrontWindow(),MAPPER_INFO_MAXX)
minY = MapperInfo(FrontWindow(),MAPPER_INFO_MINY)
maxY = MapperInfo(FrontWindow(),MAPPER_INFO_MAXY)

' - mapper window coordinates
Set Map Window FrontWindow() Layer 0 Editable On
Create Point (minX,maxY) Symbol (69,0,24,"MapInfo Cartographic",0,0)  
Create Point (maxX,maxY) Symbol (69,0,24,"MapInfo Cartographic",0,0)
Create Point (maxX,minY) Symbol (69,0,24,"MapInfo Cartographic",0,0)
Create Point (minX,minY) Symbol (69,0,24,"MapInfo Cartographic",0,0)
'=================================================================
' minY i max Y coordinate calculation
dX = maxX - minX
dY = maxY - minY

Rcm = dX/w_MapFrame
R = Rcm*100
b1 = dY/R*100
b2 = (h_MapFrame-b1)/2
Yp = b2*R/100
LmaxY = maxY + Yp
LminY = minY - Yp

' - corner points of layout map frame
Create Point (minX,LmaxY) Symbol (69,0,48,"MapInfo Cartographic",0,0)
Create Point (maxX,LmaxY) Symbol (69,0,48,"MapInfo Cartographic",0,0)
Create Point (maxX,LminY) Symbol (69,0,48,"MapInfo Cartographic",0,0)
Create Point (minX,LminY) Symbol (69,0,48,"MapInfo Cartographic",0,0)

'==============================================================
' Layout creation
'==============================================================

Layout
Position (0,0) Units "cm"
Width (w_Pap-mar*2) Units "cm" 
Height (h_Pap-mar*2) Units "cm"
Max
  
  iLayoutWindowID = WindowID(FrontWindow())
Set CoordSys Layout Units "cm"
'==============================================================
' layout points
'==============================================================

' - frame points
f1.x = pT.x
f1.y = pT.y

f2.x = pT.x+w_MapFrame
f2.y = pT.y

f3.x = pT.x
f3.y = pT.y+h_MapFrame

f4.x = pT.x+w_MapFrame
f4.y = pT.y+h_MapFrame

' - table points
t1.x = f3.x 
t1.y = f3.y

t2.x = f4.x 
t2.y = f4.y

t3.x = t1.x
t3.y = t1.y+h_Table

t4.x = t1.x+w_Table
t4.y = t2.y+h_Table
'==============================================================
' Map frame in Layout

Create Frame (f1.x,f1.y) (f4.x, f4.y)
Pen (20,65,16777215) 
Brush (2,16777215,16777215)
From Window iMapWindowID
FillFrame On

'==============================================================
' 4 symbols for corners

Create Point (f1.x, f1.y) Symbol (69,0,24,"MapInfo Cartographic",0,0) 
Create Point (f2.x, f2.y) Symbol (69,0,24,"MapInfo Cartographic",0,0) 
Create Point (f3.x, f3.y) Symbol (69,0,24,"MapInfo Cartographic",0,0) 
Create Point (f4.x, f4.y) Symbol (69,0,24,"MapInfo Cartographic",0,0) 
 
' label of real world coordinates 
' Upper left minX*maxY
Create Text str$(minX) (f1.x-0.4, f1.y+1.6) (f1.x+1.95, f1.y+2.7) Font ("Arial",0,8,6316128,16777215) Angle 90
Create Text str$(LmaxY) (f1.x+0.1, f1.y-0.4) (f1.x+2.35, f1.y) Font ("Arial",0,8,6316128,16777215)

' upper right maxX*maxY
Create Text str$(maxX) (f2.x+0.05,f2.y+1.6) (f2.x+2.5, f2.y+2.0) Font ("Arial",0,8,6316128,16777215) Angle 90
Create Text str$(LmaxY) (f2.x-0.6, f2.y+1.6) (f2.x-1.6, f2.y-0.4) Font ("Arial",0,8,6316128,16777215)

' down left minX*minY
Create Text str$(minX) (f3.x-0.4,f3.y-0.1) (f3.x+2.5, f3.y+2.0) Font ("Arial",0,8,6316128,16777215) Angle 90
Create Text str$(LminY) (f3.x+0.1, f3.y-0.45) (f3.x+2.35, f3.y) Font ("Arial",256,8,6316128,16777215)

' down right maxX*minY
Create Text str$(maxX) (f4.x+0.05,f4.y-0.1) (f4.x+2.5, f4.y+2.0) Font ("Arial",0,8,6316128,16777215) Angle 90
Create Text str$(LminY) (f4.x-0.6, f4.y+1.6) (f4.x-1.6, f4.y-0.45) Font ("Arial",256,8,6316128,16777215)
Set Layout Ruler On Pagebreaks On Frame Contents On
' Zoom 82.0466 Center (3.98168,5.6053) Extents To Fit
Set Window FrontWindow() Autoscroll On Snap Mode On Enhanced On
' Run Command uniqueStringName
  
Set Window FrontWindow() Title " ("+s_Paper+"-"+s_Orient+")"
dim kom as string
kom = "Set Window FrontWindow() Printer Name """+sPrinterName+""" Orientation "+s_Orient+" Copies 1 Papersize "+i_Paper+""
' Print kom
run command kom
End Sub

--------------------------------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages