procedure TMainMap.Map1ToolUsed(Sender: TObject; ToolNum: Smallint; X1, Y1,
  X2, Y2, Distance: Double; Shift, Ctrl: Wordbool;
  var EnableDefault: Wordbool);var
    newObj : Variant; // Used for storing new feature object
    pt : Variant;     // Used for storing point of click
    pts : Variant;    // Used for storing collection of points
    ftrs : Variant;   // Used for storing collection of features
     vEmpty : OleVariant;
begin
        TVarData(vEmpty).vType := varError;
        TVarData(vEmpty).vinteger := DISP_E_PARAMNOTFOUND;
     Case ToolNum of
        CUSTOM_POINT_TOOL :
        // Set feature type to be a symbol, set its style & XY values.
        // Add it to editing layer
           begin
              pt := CreateOleObject('MapX.Point.4');
              pt.Set(X1, Y1);              newObj := Map1.ControlInterface.FeatureFactory.CreateSymbol(pt, Map1.DefaultStyle);
              EditLayer.AddFeature(newObj);
           end;
        CUSTOM_LINE_TOOL :
           begin           // Create new point object and points collection object              pts := CreateOleObject('MapX.Points.4');
           // set Point obect to click 1 and add it to collection
              pts.AddXY(X1, Y1);
           // set Point obect to click 2 and add it to collection
              pts.AddXY(X2, Y2);
           // Create the line & add feature to layer
              newObj := Map1.ControlInterface.FeatureFactory.CreateLine(pts, Map1.DefaultStyle);
              EditLayer.AddFeature(newObj);
           // UnAssign Variant Variables
              VarClear(pts);
           end;
        CUSTOM_INFO_TOOL :
           begin
           // Create point object and set it to click XY
              pt := CreateOleObject('MapX.Point.4');
              pt.Set(X1,Y1);
           // Perform a search at click point
              Ftrs := EditLayer.SearchAtPoint(pt);
           // If one feature selected, assign it to infoFeature and call the
           // Information form
              if Ftrs.Count = 1 Then
                 begin
                    infoFeature := Ftrs.Item(1);
                    EditLayer.DeleteFeature(infoFeature);
                   //eatureInfoForm.ShowModal;
                 end;
           // UnAssign Variant Variable
              VarClear(pt);
           end;
        CUSTOM_SELECT_TOOL :
           //Make selection on feature layer
             if (ctrl) then
               ftrLayer.Selection.SelectByPoint(X1, Y1, miSelectionAppend)
             else if (Shift) then
               ftrLayer.Selection.SelectByPoint(X1, Y1, miSelectionRemove)
             else
               ftrLayer.Selection.SelectByPoint(X1, Y1, miSelectionNew);
        //闪烁代码
        CUSTOM_GLINT_SELECT:
        begin
            pt := CreateOleObject('MapX.Point.4');
              pt.Set(X1,Y1);
           // Perform a search at click point
              Ftrs := map1.Layers.Item('usa').SearchAtPoint(pt,miSearchResultAll);
           // If one feature selected, assign it to infoFeature and call the
           // Information form
              if Ftrs.Count = 1 Then
                 begin
                   icount:=1;
                    infoFeature := Ftrs.Item(1);
                    map1.Layers.Item('temp').AddFeature(infoFeature,vEmpty) ;
                
                    timer1.Enabled :=true;
                   
                 end;
           // UnAssign Variant Variable
              VarClear(pt);        end;
     end;//Case
     // UnAssign Variant Variable
     VarClear(newObj);
end;