Community of VE/MapPoint Users and Developers
This is a discussion on Control Height and Width of images saved using MapPoint lib within the MapPoint 2006/2009 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), ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Control Height and Width of images saved using MapPoint lib 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. |
| ||||
|
What size are you trying to save as? Post you line of code that set the size so we can have a look.
__________________ John http://www.support-pc.com Order MapPoint 2006 Here https://secure.mp2kmag.com/?refer=support-PC |
| |||
|
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
|
| ||||
|
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
__________________ John http://www.support-pc.com Order MapPoint 2006 Here https://secure.mp2kmag.com/?refer=support-PC |
![]() |
| Tags |
| control, height, images, lib, mappoint, saved, width |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Controling Width of line | Anonymous | MapPoint 2006/2009 Discussion | 1 | 11-23-2004 12:43 AM |
| Is there a way to get the altitude (height above m.... | Anonymous | MapPoint 2006/2009 Discussion | 4 | 09-08-2004 02:16 PM |
| Displaying bit-mapped (raster) images in MapPoint | Anonymous | MapPoint 2006/2009 Discussion | 0 | 01-31-2004 12:00 PM |
| MapPoint Licensing - Posting static images to a website | donerb | MapPoint 2006/2009 Discussion | 2 | 07-21-2003 06:25 PM |
| Where are the saved property in mappoint | Anonymous | MapPoint 2006/2009 Discussion | 1 | 05-15-2003 07:33 AM |