MapInfo Pro Developers User Group

 View Only
  • 1.  Map window

    Posted 02-03-2020 16:31
    When I minimize MapInfo 2019 to half of my monitor screen (First Image), I am able to see the whole map but when I enlarge my whole monitor (Second Image), I can only see partial partial of my map? Does anyone know why? 



    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------


  • 2.  RE: Map window

    Employee
    Posted 02-04-2020 01:56
    Hi Michel

    It's a bit hard to tell what's going on as we only see a small part of the MapInfo Pro window. But it looks weird if your map is zoomed in that much after a resize.

    MapInfo Pro gives you two ways to handle resizing windows:
    • Fit Map to New Window
    • Preserve Current Scale
    You can find these on the Backstage via the PRO tab, under Options, Map Window. This setting will affect all new map windows

    For existing windows, you can change the settings by right-clicking on the map in the Explorer window and selecting Map Options.

    Can you try to change your setting via the last option and see if that makes a difference?

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 3.  RE: Map window

    Posted 02-04-2020 10:55
    Edited by Michel Li 02-04-2020 11:09
    Sub ReScaleMaps(ByVal tnNewWin As Integer, ByVal tnWinExist As Integer, toFrame As Object, tcMapUnit As String, tnScale As Float, ByVal x1 As Float, ByVal y1 As Float, ByVal x2 As Float, ByVal y2 As Float) 
    
    	OnError Goto DisplayError
    
    	Set Window tnWinExist 
    		Width (3.0 * (x2 - x1) / 3.0)
    		Height (3.0 * (y2 - y1) / 3.0)
    
    	Dim lnFrameWidth As Float
    	Dim lnMapZoom As Float
    
    	' If mapunits different from existing change current one
    	If MapperInfo(tnWinExist, MAPPER_INFO_DISTUNITS) <> tcMapUnit Then
    		Set Map Window tnWinExist Distance Units tcMapUnit 
    	End If
    
    	' Calculate new Zoom
    	' framewidth is value in inch
    	lnFrameWidth = ObjectGeography(toFrame, OBJ_GEO_MAXX) - ObjectGeography(toFrame, OBJ_GEO_MINX)
    
    	lnMapZoom = lnFrameWidth * tnScale
    
    	' Set Map Width to achieve desired scale
    	Set Map Window tnWinExist Zoom lnMapZoom Units tcMapUnit
    
    	Set Map Scale 1 Units "in" for tnScale Units "ft" 
    
    	Set Window tnNewWin
    		Position (1, 1)
    		Width (3.0 * (x2 - x1) / 3.0)
    		Height (3.0 * (y2 - y1) / 3.0)
    
    	Set Layout
    		Window tnNewWin
    		Zoom To Fit
    
    	Exit Sub
    
    	DisplayError:
    		Note "Error " + Error$()
    		Exit Sub
    
    End Sub
    
    '***********************************'
    Peter,

    I tried this and it still does not work. What my program does is it is generating automatically the layout map. Here is my code. Maybe you will be able to find what is wrong with it. IT works on version 12.5 but not 2019.

    OnError Goto DisplayError
    
    	Dim lnWinExist As Integer	
    	lnWinExist = GetMapWindowID()
    	If (lnWinExist = 0) Then
    		Exit Sub
    	End If
    
    	Set Window lnWinExist Front
    
    	If Not PrerequisitesCheck() Then
    		Exit Sub
    	End If
    
            Dim lcFormat As String
    	Dim loFrame As Object
    	Dim lnScale As Float
    	Dim lcMapUnit As String
    
    	lcFormat = "8.5"" x 11"""
    	lcMapUnit = "ft"
    	lnScale = (MapperInfo(lnWinExist, MAPPER_INFO_SCALE) * 5280.0)
    
    	Set Event Processing Off
    	Set CoordSys Layout Units "in"
    
    	Dim loCenter As Object
    	Dim lcProperty As String
    
    	Call GetTargetPropertyWithType(loCenter, lcProperty)
    
    	Dim lnNewWin As Integer
    
    	' 8 x 11 Pyyyyyy
    	Run Application "J:\GeoApps\MapLayouts\8X11P\Preliminary.wor"
    
    	lnNewWin = FrontWindow()
    
    	Set Layout Window lnNewWin Frame Contents Off
    
    	loFrame = StampMapWindow(lnNewWin, lnWinExist, lcFormat, 0.7479, 1.1167, 7.7417, 8.2007)
    
    	Call ReScaleMaps(lnNewWin, lnWinExist, loFrame, lcMapUnit, lnScale, 0.7479, 1.1167, 7.7417, 8.2007)
    
    	Call StampJobNumber(lnNewWin, 0.7535, 10.3701)
    
    	Call StampSiteInfo(loCenter, lnNewWin, 3.4646, 8.2382, 0, False)
    	Call StampNorthArrow(lnNewWin, 6.9375, 8.7000)
    	Call StampScale(lnNewWin, lnWinExist, lnScale, 6.0965, 9.3625)
    
    	Call StampSymbols(lnNewWin, 0.8653, 8.3090, 9.0, lcProperty, False) 
    	
    	Set Window FrontWindow() Printer
    		Name "Adobe PDF" Orientation Portrait Copies 1
    		Papersize 1
    
    	Set CoordSys Earth Projection 1, 74
    
    	Call ReCenterMap(lnWinExist, loCenter)
    
    	Set Window FrontWindow() Title "Preliminary" + MAPEXTENSION
    
    	' Redraw the Layout window, when necessary, to reflect changes in the client window(s)
    	Set Event Processing On
     	Set Layout Window lnNewWin Frame Contents On
    
    	If (tlResize) Then
    		Set Map Window lnWinExist Zoom Entire Layer Boundaries
    		Update Window lnWinExist
    	End If
    
    	Update Window lnNewWin 
    
    	Exit Sub
    
    	DisplayError:
    
    		Note "Error " + Error$()
    		Exit Sub
    
    End Sub
    ​


    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------



  • 4.  RE: Map window

    Employee
    Posted 02-06-2020 04:41

    Hi Michel

    There is a major difference between MapInfo Pro v12.5 and MapInfo Pro v2019: In the layout, the frame with the map doesn't link back to an existing map, it contains the map.

    This means that once you have inserted a map into a frame in your layout, you need to access this map in order to change it, say it's zoom and center.

    Here's a very basic example of how you can create a layout, add an empty frame and then fill that frame with an existing map window. Afterwards, you get the ID of the map in the frame and can modify the map using Set Map.


    '**Create a new Layout
    Dim nMapID As Integer

    nMapID = FrontWindow()
    Layout Designer

    ***Create an empty frame in the layout
    Set Coordsys Layout Units "in"
    Create Frame (0.3583,0.2917) (4.8583, 4.25)
       Name "No Content"

    '**Insert an existing map into the empty frame
    Set Designer Frame Id 1
       From Window nMapID
    Dim nMapLayoutID As Integer

    nMapLayoutID = WindowID(0)

    '**Change the map in the layout frame
    Set Map

       Window nMapLayoutID
       CoordSys Earth Projection 12, 104, "m", 0
       Center (841561.0314,5952105.328)
       Zoom 934332.2571 Units "m"

    I hope this helps

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 5.  RE: Map window

    Posted 02-06-2020 09:49
    Peter,

    Thanks it does help. In version 12.5, I called the workspace for the layout. Do I do the same call in version 2019?

    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------



  • 6.  RE: Map window

    Employee
    Posted 02-06-2020 09:54
    Sure, that can done, Michel.

    Open the workspace and find the empty frame you want to use and use my code from this statement onwards:

    '**Insert an existing map into the empty frame
    Set Designer Frame Id 1
       From Window nMapID

    Adjust it to your own needs

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 7.  RE: Map window

    Posted 02-06-2020 11:12
    Thanks Peter. You are very helpful. It is hard to switch from 12.5 to version 2019. Without your help I will be lost. Thanks again for all your help.

    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------