The one page mapping with CustomLayer described how to draw lines on a map. The other page mapping with points indicates how to label bitmaps on a map. Now we would like to combine both examples in order to draw lines between start and destination flags. This example is used to draw so called "spider lines". The start flag is located in the center of the destination flags.
The target is to create Lines and Bitmaps together. We skip the details, because they are documented in the above mentioned samples.
Define arrays of Lines[] and Bitmap[].
Lines[] lines = new Lines[numberOfDestinationPoints]; // ... define each line Bitmap[] arrBitmap = new Bitmap[numberOfDestinationPoints+1]; //plus the source point itself // ... define each bitmap
You don't have to create separate layers for lines and points (but you may); you can put both into the same CustomLayer as shown below.
Set lines and flags into the customLayer. Use only one layer for this operation.
CustomLayer customLayer = new CustomLayer(); customLayer.setDrawPriority(25000); customLayer.setName("Text layer"); customLayer.setObjectInfos(ObjectInfoType.REFERENCEPOINT); customLayer.setVisible(true); customLayer.setBitmaps(arrBitmaps); // Bitmaps customLayer.setLines(lines); // Lines
The example mapping with points and lines is also executable as a stand-alone java program.
Copyright © 2024 PTV Logistics GmbH All rights reserved. | Imprint