Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 5 of 5

Control Height and Width of images saved using MapPoint lib

This is a discussion on Control Height and Width of images saved using MapPoint lib within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, I am using .NET to access the MapPoint 11.0 (2004) object library to open about 20 pre-saved Maps (.ptm), ...

  1. #1
    kdulaney is offline Junior Member White Belt
    Join Date
    Jan 2005
    Posts
    8

    Control Height and Width of images saved using MapPoint lib

    Hi, I am using .NET to access the MapPoint 11.0 (2004) object library to open about 20 pre-saved Maps (.ptm), update the linked data (.csv) and then save the resulting maps as web pages. I then use the resulting .gif image.

    Since the Map object's height and width properties are read-only, I have been trying to use the App object to set the height and width at the application level - adjusting for the menu, toolbar, etc..

    However, it seems that the resulting .gif images are not the desired size and what's even more troubling is that they are not all the same even though they were created using the same App object with the same height/width settings at that level.

    If I open the .ptm file that is already sized to the proper dimensions and perform a "Save as web page" from the application, the image is the proper size.

    Is there any way to control this from code that produces consistent results?

    Thank you.

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    What size are you trying to save as?

    Post you line of code that set the size so we can have a look.

  3. #3
    kdulaney is offline Junior Member White Belt
    Join Date
    Jan 2005
    Posts
    8
    John,

    Thanks for your reply.

    I am trying to save the images at 760 x 570. After further testing over the weekend, I have found that I can run my console application from a command prompt or from Windows Explorer and the images are produced in the correct size.

    However, when i run the .exe from a scheduler (Arcana or Windows AT) or from a batch file that only calls the .exe, the images come out at 760 x 455. Same compiled .exe, Same .config file. I have also created my application to run as a Windows service and it produces the same size images (760 x 455). I have tried running them under my domain/user and as a local system account and that made no difference.

    I am at a loss as to what could be happening. If you can double-click on the .exe file and run it from explorer and it produces the expected results, what could MapPoint be doing that would cause it to work differently from a scheduler, batch file or service?

    Here is the code where i am setting the size of the images to save. The "Output" sub is where the sizes get set and the images get saved.

    Thank you very much for you help. It is greatly appreciated.
    Kevin

    Code:
          Public Sub New()
                log.Debug("Creating MapPoint.Application object")
    
                m_objApp = New MapPoint.Application()
    
                'log.Debug("Setting UserControl invisible.")
                'm_objApp.Visible = False
                'm_objApp.UserControl = False
            End Sub
    
            Public Sub Dispose()
                log.Debug("Quitting Application")
                CType(m_objApp, MapPoint._Application).Quit()
            End Sub
    
            Public Sub Output()
                log.Debug("Entering Output Sub")
    
                Dim _objMap As MapPoint.MapClass
    
                'The MapPoint .ptm folder and file to open
                Dim _projectFilename As String
                _projectFilename = m_MapPointProjectFolder & "\" & m_MapPointProjectName
    
                log.Debug("Filename = " & _projectFilename)
    
                'The name of the folder and file to save the html as
                Dim _dirInfoOutput As New DirectoryInfo(m_ImageOutputFolder)
                If Not _dirInfoOutput.Exists Then
                    log.Debug("Directory " & _dirInfoOutput.FullName & " does not exist.")
                    _dirInfoOutput.Create()
                    log.Debug("Directory " & _dirInfoOutput.FullName & " created.")
                End If
    
                Dim _projectSaveAs As String
                _projectSaveAs = m_ImageOutputFolder & "\" & m_ImageOutputFilename
    
                Try
                    'Open an existing .ptm file
                    log.Debug("Opening Map Project " & _projectFilename)
                    _objMap = m_objApp.OpenMap(_projectFilename, False)
                Catch ex As Exception
                    log.Fatal("Failed to open Map Project " & _projectFilename, ex)
                    Throw New ApplicationException("WTFO", ex)
                End Try
    
                log.Debug("Map Opened ")
                m_objApp.Height = m_ImageOutputHeight + m_ImageOutputHeightAdjustment
                m_objApp.Width = m_ImageOutputWidth + m_ImageOutputWidthAdjustment
                log.Debug("App Height = " & m_objApp.Height & ". App Width = " & m_objApp.Width)
                log.Debug("Map Height = " & _objMap.Height & ". Map Width = " & _objMap.Width)
                log.Debug("Config Map Height = " & m_ImageOutputHeight & ". Config Map Width = " & m_ImageOutputWidth)
                log.Debug("Config Map Height Adj = " & m_ImageOutputHeightAdjustment & ". Config Map Width Adj = " & m_ImageOutputWidthAdjustment)
    
                Try
                    'Update the data linked to the map
                    log.Debug("Updating linked data. Name(" & m_objApp.Application.ActiveMap.DataSets(1).SourceFullName & ") Source(" & m_objApp.Application.ActiveMap.DataSets(1).SourceFullName & ")")
                    m_objApp.ActiveMap.DataSets(1).UpdateLink()
                    log.Debug("Linked data updated successfully.")
    
                Catch ex As Exception
                    log.Fatal("Unable to update linked data.", ex)
                End Try
    
                Try
                    log.Debug("Saving Map as Web Page.")
                    'Save the map as a web page with supporting files
                    _objMap.SaveAs(_projectSaveAs, GeoSaveFormat.geoFormatHTMLMap, False)
    
                    log.Debug(_projectSaveAs & " saved as web page.")
                Catch ex As Exception
                    log.Fatal("Unable to save map as html.", ex)
                End Try
    
                Try
                    'log.Debug("Saving Map.")
                    'Tell the application that the map is saved even though
                    'we don't want to save it.
                    m_objApp.ActiveMap.Saved = True
                    'Save the Map
                    'm_objApp.ActiveMap.Save()
                    'log.Debug("Map Saved.")
    
                Catch ex As Exception
                    log.Error("Unable to save map.", ex)
                Finally
                    'Clean up
                    _objMap = Nothing
                End Try
    
            End Sub

  4. #4
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    Kevin,
    You need to use the 'SavedWebPages property' to set Map size in pixels to your required size rather than change the size of the app. Here is a modified sample from the helpfile.

    Hope this helps. Let us know either way...

    John

    Code:
    Dim objApp As New MapPoint.Application
      Dim objMap As MapPoint.Map
      Dim objRoute As MapPoint.Route
      Dim objSW As MapPoint.SavedWebPage
    
      'Set up the application
      Set objMap = objApp.ActiveMap
      Set objRoute = objMap.ActiveRoute
      objApp.Visible = True
      objApp.UserControl = True
    
      'Create a route
      objRoute.Waypoints.Add objMap.FindResults("Seattle, WA").Item(1)
      objRoute.Waypoints.Add objMap.FindResults("Redmond, WA").Item(1)
      objRoute.Calculate
    
      'Use SavedWebPages property to create a saved Web page
      Set objSW = objMap.SavedWebPages.Add("SavedWeb", _
        objRoute.Waypoints.Item(1).Location, "New Title", _
        True, False, True, 760, 570, False, True, False, True)
      objSW.Save

  5. #5
    .NET Chatting House is offline Junior Member White Belt
    Join Date
    Dec 2012
    Posts
    2

    Re: Control Height and Width of images saved using MapPoint lib

    hi, hmmm, I agree with John Meyer, you can change the setting to get a proper pixel, change the map size does not help much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Controling Width of line
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-23-2004, 12:43 AM
  2. Is there a way to get the altitude (height above m....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 09-08-2004, 02:16 PM
  3. Displaying bit-mapped (raster) images in MapPoint
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 01-31-2004, 12:00 PM
  4. MapPoint Licensing - Posting static images to a website
    By donerb in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 07-21-2003, 06:25 PM
  5. Where are the saved property in mappoint
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-15-2003, 07:33 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27