cFactory.CombineFeatures(features);

 求助:创建折线出错
我的代码如下:
long count = points.GetCount() - 1;
CMapXFeatures features;
CMapXFeature feature;
CMapXPoints linePoints;
linePoints.CreateDispatch(linePoints.GetClsid());
for (long i = 1; i <= count; i++) {
 linePoints.RemoveAll();
 linePoints.Add(points.Item(i));
 linePoints.Add(points.Item(i + 1));
 COleVariant vtPoints;
 vtPoints.vt = VT_DISPATCH;
 vtPoints.pdispVal = linePoints.m_lpDispatch;
 vtPoints.pdispVal->AddRef();
 feature = cFactory.CreateLine(vtPoints,vtStyle);
 features.Add(feature);
}
 
cFactory.CreateCollectionFeature(features)
feature=cFactory.CombineFeatures(features);
执行最后一句cFactory.CombineFeatures(features);时,报异常 。
另外,我还问一下,创建折线有没有其它方法。我用这种方式来做对不对啊


Private Sub mnuEditConsociate_Click()
On Error Resume Next
Dim Layer As MapXLib.Layer
Dim Ftr As MapXLib.Feature
Dim Ftrs As MapXLib.Features
Dim FtrCombined As MapXLib.Feature
Dim StyCombined As New MapXLib.Style
Dim FtrType As MapXLib.FeatureEditModeConstants

   
    If Trim(cbLayers.Text) = "" Then Exit Sub
    Set Layer = Map.Layers(Trim(cbLayers.Text))
   
    If Layer.Selection.Count <= 1 Then
         MsgBox "至少选择两个编辑对象!"
        Exit Sub
    End If
   
    Set Ftrs = Layer.Selection
   
   
   
    '生成合并后的新图元,并添加到地图
    Set Ftr = Map.FeatureFactory.CombineFeatures(Ftrs)
    Layer.AddFeature Ftr
   
    '设置合并后新图元的样式为合并前图元的样式
    Set StyCombined = Ftrs(1).Style.Clone
    FtrCombined.Style = StyCombined
    FtrCombined.Update
   
    '删除合并前的图元
    For Each Ftr In Ftrs
        Layer.DeleteFeature Ftr
    Next Ftr
   
    '使合并后的图元处于选中状态
    Layer.Selection.Replace FtrCombined
End Sub

原文地址:https://www.cnblogs.com/googlegis/p/2978901.html