MAPX development in Delphi

xiaoxiao2021-03-05  28

First, after installing MAPX, select Delphi's Component -> Import Active menu added, MapInfo Mapx component. After the addition is completed, a TMAP control will come out on the ActiveX panel. Second, drag a TMAP control to the project to be renamed as mainmap, which produces a TMAP object. Third, create a layer on the map using the CreateLayer function of the Layers property to create a layer MainMap.Layers.CreateLayer (Name, [Filespec], [POSITION], [Keylength], [COORDSYS]); Parameter Description: Name: Specify The name of the layer FILESPEC: The path name of the layer is created. Such as 'c: /china.tab' Position: It is in the initial location in the list list. (It is a serial number in the layer list) COORSYS: Specifies the coordinate system of the stored new layer. Fourth, the layer type parameters: miLayerTypeNormal miLayerTypeRaster miLayerTypeSeamless miLayerTypeUnknown miLayerTypeUserDraw miLayerTypeDrilldown five, FeatureFactory object's method allows you to create a new map features, but also on existing elements to perform operations (such as buffers) to create elements through. The following methods are FeatureFactory object: BufferFeatures CombineFeatures CreateArc CreateCircularRegion CreateEllipticalRegion CreateLine CreateRegion CreateSymbol CreateText EraseFeature IntersectFeatures IntersectionPoints IntersectionTest six, using a custom bitmap is defined in the symbol cs primitives: CMapXStyle as primitive Style property cs: = coStyle. Create; cs.symeboltype: = misymboltypebitmap; cs.symbolbitmapname: = 'hous2-32.bmp'; cs.symbolbitmapsize: = 40; Note: Custom bitmap must be placed in C: / Program Files / Common files / mapInfo Under Shared / Mapx Common / CustSymb, this is a configucy shared path installed by MapInfo.

Seven, the screen coordinates to map coordinates of the conversion procedure TMapForm.Map1MouseUp (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var lon, lat: Double; singleX, singleY: Single; fs: CMapXFeatures; pnt: CMapXPoint; name: String; begin if Map1.CurrentTool = miArrowTool then begin pnt: = CoPoint.Create; singleX: = X; singleY: = Y; Map1.ConvertCoord (singleX, singleY, lon, lat, miScreenToMap); pnt .SET_ (LON, LAT); FS: = Map1.Layers. Item ('US Top 20 Cities'). Searchatpoint (PNT); if Fs.count> 0 Then Begin Name: = fs.Item (1) .name Application.MessageBox (Pchame), 'Info', 0) Else Application.MessageBox ('Nothing Found', 'No.', 0); End;

Note: It is best to use Layer.GetFeatureByid (FeatureKey) when getting a primitive;

转载请注明原文地址:https://www.9cbs.com/read-33418.html

New Post(0)