Use Cases > PTV xMap > How to Set Points and Lines in the Map

How to Set Points and Lines in the Map

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.

Creating Lines and Bitmaps

The target is to create Lines and Bitmaps together. We skip the details, because they are documented in the above mentioned samples.

Java snippet

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

Layer with Lines and Bitmaps

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.

Java snippet

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

Source Code

The example mapping with points and lines is also executable as a stand-alone java program.