Static Map

The static map is an image captured by the request of a navigation REST API. This code uses the GOF build pattern.

Image Sample

Requirements

Dependecy

You need to add in your pom file within your dependencies tag the dependency:

After downloading the dependency it will be necessary to generate the tcz of the dependency so that it is included in the deploy

Find the folder that is located in the dependency, usually is: C:\Users\your_user\.m2\repository\com\totalcross\utils\tc-utilities\0.0.1-SNAPSHOT

To generate tcz execute the command java -cp "% TOTALCROSS 3_HOME%" / dist / totalcross-sdk.jar tc.Deploy tc-utilities-0.0.1-SNAPSHOT.jar / r YOUR_TC_KEY

After tcz is generated, rename the tc-utilities-0.0.1-SNAPSHOT.tcz file to tc-utilities-0.0.1-SNAPSHOTLib.tcz and place it at the root of the project.

At the root of the project create the file named all.pkg and put [L] tc-utilities-0.0.1-SNAPSHOTLib.tcz so that this class is included in deploy

KEY

in the example below, the class was made considering the API HERE, to get an APP ID and APP CODE you have to register on the site and create a project, going into the details of the project you will find this information.

The 3 points are only to represent in a more playful way that there are other dependencies

Static Map Structures

in the example below the class was made considering the API HERE

Create in util package a new class StaticMap

The 3 points are only to represent in a more playful way that there are other package.

Static Map Code

Atributes

Description

String adress

It receives an address, as in the example: "Av. Washington Soares, 1321 - Edson Queiroz, Fortaleza - CE, 60811-905"

double latitude

it receives a latitude

double logitude

it receives a latitude

int width

Image width

int height

Image height

int zoom

The zoom that is applied in the map photo, going from zero (Vision farther) to 21, where 21 will give the view of the whole state and between 0 to 21 it is possible to adjust how close the image is seen.

int format

Indicates the format of the image received

Boolean mapHeader

Remove or place the map header

String mapStyle

Changes the map style received in the image

How to use

Within the InitUi (), you can declare an image and receive its instance by calling the StaticMap getImage method

References

See this link for more information abount GOF patterns.

Last updated

Was this helpful?