ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Slippy map opaque layer

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bmesser Posted - Aug 13 2019 : 11:50:03
Hi

Does anyone know if it's possible to create an opaque over layer when using TIESlippyMaps?

I would like to create a multi-point coloured polygon area for a county or region and still partially see the map beneath.

I may well have asked this question before but can't be sure what the answer was!

Bruce.
6   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Aug 16 2019 : 16:52:09
Nice work

Nigel
Xequte Software
www.imageen.com
bmesser Posted - Aug 16 2019 : 05:25:05
Hi Nigel

For a moment I thought that I would have to email you back saying I still couldn't clear the canvas when I dragged the map.

Then I found the ImageDrawLayers method and the penny dropped. It's perfectly fast enough for what I do but opens up a new way of doing things to me!

procedure ImageDrawLayer(Sender: TObject; Dest: TIEBitmap; LayerIndex: Integer);
var
  pts : TPointArray;
  i   : integer;
begin
  if LayerIndex=1 then
  begin
    SetLength(pts,length(Warnings[0].Coordinates));

    for i:=0 to length(Warnings[0].Coordinates)-1 do
    begin
      pts[i].X:=map.LongitudeToBmpX(Warnings[0].Coordinates[i].Lon);
      pts[i].Y:=map.LatitudeToBmpY(Warnings[0].Coordinates[i].Lat);
    end;

    with Dest.IECanvas do
    begin
      Pen.Mode := pmCopy;
      Pen.Width :=2;
      Pen.Style := psSolid;
      Pen.Color := clBlack;
      Pen.Transparency := 192;

      Brush.Color := clYellow;
      Brush.Style := bsSolid;
      Brush.Transparency := 128;
      Polygon(pts);
    end;
  end;
end;




Thanks again - the mapping that comes as an extra with the ImageEn component library is an absolute godsend to me.

Bruce.
xequte Posted - Aug 15 2019 : 21:55:32
Hi Bruce

Sorry, i should have steered you more directly to the drawing option.

Please take a look at: \InputOutput\GeoMaps\

It uses RenderToTBitmapEx, which has Transparency as a parameter. You can set it to 128 to draw at 50% transparency.

I would do something like:

1. Generate your pts list using LongitudeToBmpX/LatitudeToBmpY
2. find the min and max x and y in your array
3. Create bitmap of size maxX - minX, maxY - minY
4. Make offsetX := minX and offsetY := minY
5. Subtract offsetX and offsetY from all points
6. Draw a polygon to the TIEBitmap.IECanvas
7. Render the polygon at offsetX, offsetY using RenderToTBitmapEx

Of course, you could skip steps 2-5 and just use an image of the size of the client (and decide whether the performance is acceptable).

You might also consider caching the bitmaps too for performance.

For tips on using a TIECanvas, see the polygon example at:

https://www.imageen.com/help/TIECanvas.html



Nigel
Xequte Software
www.imageen.com
bmesser Posted - Aug 15 2019 : 14:58:54
Hi Nigel

I tried as you suggested drawing a filled polygon on a transparent layer using this code:

Image.LayersAdd;
Image.Layers[1].Opacity:=0.5;

procedure TfmMain.ImageDrawBackBuffer(Sender: TObject);
var
  pts : TPointArray;
  i   : integer;
begin
  SetLength(pts,length(Warnings[0].Coordinates));

  for i:=0 to length(Warnings[0].Coordinates)-1 do
  begin
    pts[i].X:=map.LongitudeToBmpX(Warnings[0].Coordinates[i].Lon);
    pts[i].Y:=map.LatitudeToBmpY(Warnings[0].Coordinates[i].Lat);
  end;
  
  with Image.Layers[1].Bitmap.Canvas do
  begin
    Pen.Color:=clBlack;
    Brush.Style:=bsSolid;
    Brush.Color:=clYellow;
    Polygon(pts);
  end;
end;  

That worked but as I drag the map with the mouse the polygon gets repeatedly redrawn:



Somewhere I need to clear the bitmap but how?

Bruce
bmesser Posted - Aug 13 2019 : 17:24:38
Thanks for your speedy reply Nigel I'll try it out tomorrow and let you know.
xequte Posted - Aug 13 2019 : 16:42:03
Hi Bruce

You can use layers:

ImageEnView1.LayersAdd( iesPinLeft, 100, 100, 120, 120 );
ImageEnView1.CurrentLayer.Opacity := 0.4;

But because slippy maps are virtually drawn, you need to concern yourself with moving them when the user scrolls.

So I think you are better to draw it yourself, as the pins are drawn in the OnDrawBackBuffer event of the \InputOutput\GeoMaps\ demo.

Nigel
Xequte Software
www.imageen.com