Error: Method 'CoordinateSystem' of object '_DMap' failed.

Error Message

When attempting to assign a ProjCoordSys object to the CoordinateSystem property of a Map or MapLayer object, the following error may occur:

Method 'CoordinateSystem' of object '_DMap' failed.


This error may occur if the ProjCoordSys object's Type property has been set equal to the Type property of another ProjCoordSys object. For example, code like this sometimes raises the error:

Dim mapPCS As New MapObjects2.ProjCoordSys
mapPCS.Type = Map1.Layers(0).CoordinateSystem.Type
Map1.CoordinateSystem = mapPCS

Solution or Workaround

Don't pass the Type property. Set the new ProjCoordSys object equal to the layer's ProjCoordSys explicitly. For example,

Dim mapPCS As New MapObjects2.ProjCoordSys
Set mapPCS = Map1.Layers(0).CoordinateSystem
Set Map1.CoordinateSystem = mapPCS