Dynamic pins on a map

Generate a map with dynamic pins with Carbone

Download Template

Download data sample

  • Template type document odp expert
  • Carbone min. v5.0.0+
  • Features transform set
  • Target maps markers longitude latitude custom

Objectives

Generate a presentation with the following features:

  • Dynamically move a pin on a map.
  • Convert latitude and longitude into X and Y coordinates on an image

Solution

Warning: For demonstration purposes, the calculation method for determining the geographical position of the marker has been greatly simplified. This is an approximation that does not follow any scientific method for converting geographical coordinates.

Here’s how to construct an ODP template to achieve this with Carbone:

  1. Insert the map in the template

  2. Define two fixed reference points on your your side

    • Record their GPS coordinates (latitude and longitude)
    • Identify their X and Y positions on the inserted map by placing a shape and noting its X and Y positions

    Example:

     Name    | PosX  | PosY  | Latitude  | Longitude
     Darwin  | 7.87  | 0.31  | -12.455   | 130.839
     Perth   | 1.58  | 8.77  | -31.953   | 115.863
    • Compute the coefficient needed for the approximate conversion :

    Example:

    CoeffX = (7,87-1.58)/(130.839-115.863) = 0,420
    CoeffY = (0.31-8.77)/(-12.455-(-31.953)) = 0,4334 
  3. Define the dynamic position of the shape

    • Keep only one shape on the map in the template, which will be used for movement
    • Right-click on the shape, go to the Alt text menu, and specify the transformations to apply to the longitude {d.location[i].longitude} and latitude {d.location[i].latitude} values, using :transform() formatter

    Example:

    {d.location[i].longitude:sub(115.863):mul(0.420):sub(7.87):add(1.58):transform(x,cm)}
    {d.location[i].latitude:sub(-31.953):mul(-0.4334):add(8.77):transform(y,cm)}

    Note: Make sure to use a shape (not an image) to apply the `transform formatter

  4. Add a placeholder

    • Insert a temporary image
    • Right-click on it, go to the Alt text menu, and specify the path of the illustrative image

    Example: {d.location[i].image}

And there you go!

You might also like

Trusted by 600+ paid customers in 40+ countries

Finance
Healthcare
Public
Retail
Industries
Energy
Software
Telecom
1dior.png
22thales.png
23younited.png
2danfoss.png
3cma-cgm.png
3illumina.svg
4KparK.png
6scalingo.png
7defense.png
8bmw.png
8telus.png
bestseller.png
flagship_bioscience.png
insly.png
ninox.png
sodexo.png