Quantcast
Channel: MapWinGIS ActiveX Map and GIS Component
Viewing all articles
Browse latest Browse all 2341

New Post: Problem Shapes with Images (GPX base map) no databases in Delphi XE3 version 4.9.3.1

$
0
0
My idea is create icons clickables into map at a coordenate.
First load a gpx file into Map component (hangs in Windows XP). The stretch draws correctly. All right,
Now I have a TImageList (component with a lot of images loaded), 2 TClientDataSet (midas for access sql remote data) and I am going populating the stretch with icons, images, labels, etc.
But.... anything shows in the map!.
I've created Categories, IconManager, in many ways.
I need help for corroborate I am doing all right

Ex.:
procedure GeneratePoint(path: String; Elem, Detail: TClientDataSet);
var mapHandle, shapeHandle: integer;
      point: Ipoint;
      sf: IShapeFile;
      shape: IShape;
      index: integer;
begin
  Map1.LockWindow(lmLock);
  Map1.RemoveAllLayers;
  mapHandler := Map1.AddLayerFromFilename(path, fosAutodetect, True);  //a gpx file. Hangs in XP
  Map1.LayerName[mapHandle] := path;
  Map1.LayerVisible[mapHandle] := True;
  // It's all right at here. The map appear.
  point := CoPoint.Create;
  sf := CoShapefile.Create;
  sf.CreateNew('', SHP_POINT);
  sf.DefaultDrawingOptions.AlignPictureByBottom := false;
  CreateCategories(sf, Elem);  

  Detail.First;
  while not Detail.Eof do begin
      Elem.Locate('ID_', Detail['ELEM_ID'],[]);
      index   := 0;
      point.x := Detail['X'];
      point.y := Detail['Y'];
      shape := CoShape.Create;
      if not shape.Create(SHP_POINT) then
        ShowMessage(shape.ErrorMsg[shape.LastErrorCode]);
      if not shape.InsertPoint(point, index)then
        ShowMessage(shape.ErrorMsg[shape.LastErrorCode]);
      if not sf.EditInsertShape(shape, index) then
        ShowMessage(sf.ErrorMsg[sf.LastErrorCode]);
      sf.ShapeCategory[sf.NumShapes] := Elem['ID_']-1;  //Fails. Assign -1
      sf.DefaultDrawingOptions.SetDefaultPointSymbol(dpsFlag);
      sf.CollisionMode := AllowCollisions;

      if sf.GenerateLabels(0, lpCentroid, True) > 0 then
        sf.Labels.Label_[0, 0].Text := 'some text';

      Detail.Next;
    end;
  shapeHandle := Map1.AddLayer(sf, true);
  if shapeHandle = -1 then
     ShowMessage(Map1.ErrorMsg[Map1.LastErrorCode]);
  Map1.LockWindow(lmUnlock);
  Map1.CursorMode := cmNone;
  Map1.MapCursor  := crsrArrow;
  Map1.Redraw;
  Map1.ZoomToLayer(mapHandle);
end;

procedure CreateCategories(var sf: IShapeFile, Elem: TClientDataSet)
var i: TMapIconType;
    category: IShapefileCategory;
begin
  for I := 1 to 20 do begin
    Elem.Locate('ID_', I,[]);
    category := sf.Categories.Add(Elem['NAME']);
    category.DrawingOptions.PointType := ptSymbolPicture;
    category.DrawingOptions.Picture   := IconManager.getIcon(I-1);
   //IconManager is a class with 20 bmp loaded in a IImage collection
  end;
end

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>