NewMap method (MappointControl)

Creates a new map. You must specify either the map region to open the default template for that region or a file name of a template to use for the new map. Returns a Map object.

Applies to

Objects: MappointControl

Syntax

object.NewMap(Template)

Parameters

Part

Description

object

Required. An expression that returns a MappointControl object.

Template

Required Variant. One of the following:

  • The file name of a MapPoint template file, as a string. If based on a custom template that was saved to a location other than the My Documents folder, the path should also be included.

  • The GeoMapRegion value:

GeoMapRegion Value Description Version
geoMapEurope 2 European map MapPoint Europe
geoMapNorthAmerica 1 North American map MapPoint North America

Remarks

  • Any references to a prior Map object are no longer valid after the NewMap method returns a new map.

  • Do not call the NewMap method within a Microsoft Visual Basic For Each...Next statement on any MapPoint collection; it will invalidate the statement.

Examples

[Visual Basic 6.0]
'Assume the MappointControl on your form is named "MPC"
Sub  Form_Load()
  Dim objMap As MappointCtl.Map
  'Use the default North American Map
  Set objMap = MPC.NewMap(geoMapNorthAmerica)
End Sub

[C#]
//Assume the MappointControl on your form is named "MPC"

private void Form1_Load(object sender, System.EventArgs e)
{
 MapPoint.Map objMap = null;

 //Use the default North American Map
 objMap = MPC.NewMap(MapPoint.GeoMapRegion.geoMapNorthAmerica);
}

[Visual Basic 6.0]
Sub  Form_Load()
  'Use a specific MapPoint template
  Dim strInstallDir as String
  strInstallDir = "C:\Program Files\Microsoft MapPoint"  'Directory in which MapPoint was installed
  Set objMap = MPC.NewMap(strInstallDir & "\Samples\SampleTemplate.ptt")
  If objMap Is Nothing Then
  ' error handling
    exit sub
  Else
  ' do something with objMap
  End If
End Sub

[C#]
private void Form1_Load(object sender, System.EventArgs e)
{
 MapPoint.Map objMap = null;
 string installDir = "C:\\Program Files\\Microsoft MapPoint"; //Directory in which MapPoint was installed

 try
 {
  objMap = MPC.NewMap(installDir + "\\Samples\\SampleTemplate.ptt");
  //do something with objMap
 }
 catch
 {
  //error handling
 }
}

Note   These samples are specifically for use in MapPoint North America; they are for illustration purposes only.