In the TMSFNCHere component I display a map from Here. I would like to temporarily overlay an additional layer with a fragment of the map in raster format on this map (on the TMSFNCHere component).
In raster format I have the location of ground research points, which I need to overlay on TMSFNCHere to map their exact location, and then hide the PNG map. I loaded the PNG raster map with a transparent background into the TImage component (specifically TscGPImage from Almediadev because it has more options than TImage).
I have a problem because I cannot overlay the raster map with a transparent background so that the transparency of the PNG file is filled with the TMSFNCHere map. Please suggest how to achieve the effect of "full transparency" - similarly to AutoCAD
Can you please specify exactly how you are adding the overlay image on the map?
I placed scGPImage in TMSFNCHere.
I set transparency for scGPImage.
Unfortunately, this transparency limits the transparent background of my PNG image to being drawn as a solid color, not as filled with the TMSFNCHere1 map.
I also set:
scGPImage1.Parent := TMSFNCHere1;
Please note that the recommended method to place images on the map is by using ElementContainers.
Make sure to set UseDefaultStyle
to False for transparency.
By default the ElementContainer is displayed in the top left corner based on X/Y coordinates.
You can use the ElementContainers.Bounds
or ElementContainers.Coordinate
properties to position the image at specific latitude/longitude coordinates.
Example:
procedure TForm1.FormCreate(Sender: TObject);
var
ec: TTMSFNCMapsElementContainer;
begin
ec := TMSFNCMaps1.ElementContainers.Add;
ec.HTML.Add('<img src="https://www.tmssoftware.com/site/img/tmslogo.png">');
ec.UseDefaultStyle := False;
end;
Thank you very much for the suggestion to use ElementContainer to insert png graphics in it.
If I understand correctly, ElementContainer is generally used to place various elements in it - such as buttons, menus, or images. Therefore, the task of ElementContainer is to store these elements. However, when placing a graphic file in ElementContainer as an "additional layer", the following problem occurs:
- When changing the orientation of the map (rotating it to the right or left), and also
- When changing the tilt of the map (switching to 3D mode)
ElementContainer tries to manage the image, but it does not do it correctly.
That's why I have a question how can I temporarily:
- Block the ability to change the map orientation using the mouse (so that it cannot be rotated to the right or left)
- Block the ability to switch from 2D to 3D using the mouse
This will prevent my png image from not being transformed when changing the map layout.
Additionally, I have a question about how I can get the current orientation of the map (rotated to the right or left). If I had such information, I could first rotate my png image by a specific angle and then reload the rotated image into the ElementContainer.
You are doing a really great job!!!
Thank you for the positive feedback!
There's currently no built-in functionality available to disable tilting and heading for Here maps. However you can use the following code to manually disable this specific functionality:
procedure TForm1.TMSFNCMaps1MapInitialized(Sender: TObject);
begin
TMSFNCMaps1.ExecuteJavaScript('mapBehavior.disable(window.H.mapevents.Behavior.Feature.TILT);');
TMSFNCMaps1.ExecuteJavaScript('mapBehavior.disable(window.H.mapevents.Behavior.Feature.HEADING);');
end;
We'll investigate if ElementContainer behavior in combination with tilting and heading changes can be improved in a future version of TMS FNC Maps.