Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Maptitude über OLE/COM steuern (https://www.delphipraxis.net/184352-maptitude-ueber-ole-com-steuern.html)

DCoderHH 19. Mär 2015 15:03

Maptitude über OLE/COM steuern
 
Hallo,

steuert hier jemand Maptitude über OLE/COM? Ich möchte eine Karte öffnen (das klappt) und dort ein Zeichen in einer bestimmten Schriftart einfügen. Den Code dazu habe ich teilweise aus der Hilfedatei nach Delphi übersetzt (hoffentlich richtig). Es läßt sich compilieren. Beim Ausführen erscheint jedoch an der Stelle "Hier der Fehler" die folgende Meldung:

Code:
C:\Users\NAME\AppData\Roaming\Caliper\Maptitude 2015\caliper.mrk was not found.
Diese Datei existiert nach einer frischen Maptitude Installation auf der gesamten Festplatte nicht. Ich vermute daher, dass der Fehler ein anderer ist und die Meldung nicht ganz stimmt. Wer kann helfen? Oder hat für mich ein anderes Beispiel, wie ich eine Maptitude-Karte von Delphi aus bearbeiten kann? Danke!


Delphi-Quellcode:
procedure TForm1.Test;
var
  spec, specSub, MapScope, Location, Color: OleVariant;
  MapName: string;
  Gisdk: OleVariant;
begin

  Gisdk := CreateOleObject('Maptitude.AutomationServer');
  Gisdk.RunMacro('OpenMap', 'D:\test.map', null);
  Gisdk.RunMacro('SetWindowSizePixels', null, 340, 270);
  Gisdk.RunMacro('SetLayer', 'Cities & Towns');

  MapName := Gisdk.RunMacro('GetMap');

    spec := VarArrayCreate([1, 4], varVariant);

    Location := Gisdk.RunMacro('Coord', -75000000, 43000000);
    spec[1] := VarArrayCreate([1, 2], varVariant);
    specSub := spec[1];
    specSub[1] := 'Location';
    specSub[2] := Location;

    spec[2] := VarArrayCreate([1, 2], varVariant);
    specSub := spec[2];
    specSub[1] := 'Font';
    specSub[2] := 'Caliper Cartographic|14';

    spec[3] := VarArrayCreate([1, 2], varVariant);
    specSub := spec[3];
    specSub[1] := 'Index';
    specSub[2] := '53';

    Color := Gisdk.RunMacro('ColorRGB', 0, 0, 65535);
    spec[4] := VarArrayCreate([1, 2], varVariant);
    specSub := spec[4];
    specSub[1] := 'Color';
    specSub[2] := Color;

    try
      Gisdk.RunMacro('AddAnnotation', 'Map|'+MapName, 'Font Character', spec); //<-- Hier der Fehler
    except
      MessageDlg(Gisdk.RunMacro('GetLastError', null), mtError, [mbOK], 0);
    end;
end;

Maptitude 23. Mär 2015 17:31

AW: Maptitude über OLE/COM steuern
 
We believe you are simply seeing the last error message left over from the application start-up (it tries to load bookmarks but none have been created yet).

The error is unrelated to your custom code.

Perhaps the problem is that the value of the Index option should be an integer, but you are using a string

DCoderHH 25. Mär 2015 07:36

AW: Maptitude über OLE/COM steuern
 
Hi, thank you very much for your reply :-)

Zitat:

Zitat von Maptitude (Beitrag 1294550)
We believe you are simply seeing the last error message left over from the application start-up (it tries to load bookmarks but none have been created yet).

The error is unrelated to your custom code.

If I start Maptitude without my application then no error message is displayed.

Zitat:

Zitat von Maptitude (Beitrag 1294550)
Perhaps the problem is that the value of the Index option should be an integer, but you are using a but you are using a string

I have changed the line
Delphi-Quellcode:
specSub[2] := '53';
to
Delphi-Quellcode:
specSub[2] := 53;

But the error is the same.

Gisdk.RunMacro raises this EOleException:
Code:
'AddAnnotation returned an error. (1)'
and GetLastError shows the error message as I have written in my first post.

Maptitude 25. Mär 2015 13:42

AW: Maptitude über OLE/COM steuern
 
Another problem is the first parameter in the call to AddAnnotation - instead of

‘Map |’ + MapName

it should be

‘Map|’ + MapName

i.e. no space character between ‘Map' and ‘|'

DCoderHH 25. Mär 2015 13:51

AW: Maptitude über OLE/COM steuern
 
Zitat:

Zitat von Maptitude (Beitrag 1294785)
Another problem is the first parameter in the call to AddAnnotation - instead of

‘Map |’ + MapName

it should be

‘Map|’ + MapName

i.e. no space character between ‘Map' and ‘|'

Thanks, but in my code is no space character:

Delphi-Quellcode:
Gisdk.RunMacro('AddAnnotation', 'Map|'+MapName, 'Font Character', spec);


(You can copy and paste it to notepad to check it. The pipe | character has some white space arround it. It may look like a space character. But it isn't)

DCoderHH 25. Mär 2015 15:01

AW: Maptitude über OLE/COM steuern
 
I have created a bookmark with Maptitude as a workaround. Now there is a file called caliper.mrk. The error message
Code:
C:\Users\NAME\AppData\Roaming\Caliper\Maptitude 2015\caliper.mrk was not found.
is gone now. But Gisdk.RunMacro raises still this EOleException:
Code:
'AddAnnotation returned an error. (1)'
But GetLastError returns another message now:
Code:
Cannot find resource Matrix.
What is the problem here? Thank you in advance :-)

Maptitude 25. Mär 2015 19:02

AW: Maptitude über OLE/COM steuern
 
Please ignore what GetLastError is reporting - these are leftover expected errors that are thrown during the application initialization. These errors have no connection with the problem you are experiencing.

DCoderHH 26. Mär 2015 08:04

AW: Maptitude über OLE/COM steuern
 
Zitat:

Zitat von Maptitude (Beitrag 1294837)
Please ignore what GetLastError is reporting - these are leftover expected errors that are thrown during the application initialization. These errors have no connection with the problem you are experiencing.

OK, I ignore GetLastError now. But how to fix the problem? The OLE-Exception is still there and AddAnnotation is not executed. It would be helpful if you would provide me a working demo. You can downlaod a free demo version of Delphi at www.embarcadero.com and try to build a working demo.

We have bought 2 licenses of Maptitude. If we get it working many of our customers will buy a license too! This 100% sure :-)

Maptitude 26. Mär 2015 18:24

AW: Maptitude über OLE/COM steuern
 
Hi:

Please review this thread: https://groups.yahoo.com/neo/groups/...ns/topics/4498

The group is a good resource for developers of Maptitude. However, we would be happy to help further.

DCoderHH 1. Apr 2015 10:00

AW: Maptitude über OLE/COM steuern
 
I've joined the Maptitude Yahoo group. But I can't write a new post. Is it possible that you (or a moderator) give me write access to this group? Thanks!


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:30 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz