{{announcement.body}}
{{announcement.title}}

Create Your Own Map Image Microservice

DZone 's Guide to

Create Your Own Map Image Microservice

Find out how to create a Map Image with microservice by deploying the HERE MapImage serverless app, AWS.

· Microservices Zone ·
Free Resource

map on wall with pins in it

Learn how to create your own Map image!

Map images provide visualizations that are vital to many web sites and applications. AWS developers can take advantage of many-core location services from HERE using the AWS Serverless Application Repository. This means developers can create their microservice to provide location services to their clients.

This post will show how you can deploy HERE MapImage Serverless Application for use in your development projects. This will allow you to access custom map images from HERE via your custom API. To accomplish this, you will need credentials at the following:

You may also like: Visualizing Microservices: Designing a Microservice System

Deploying the HERE MapImage Serverless App

After account credentials are confirmed, to find the HERE MapImage application, browse to the AWS Serverless Application Repository.

AWS screenshot

After clicking the "Browse all applications" button, you will be prompted to do your search. Type "HERE MapImage" as shown below, then select the MapImage title in the results shown.

serverless application repository

Once the landing page for the MapImage application is shown, enter your HERE credentials in the highlighted areas shown below, then deploy.

application settings

It will take a little time for the deployment process to complete. You are prepared for the next step once you see the "Application successfully deployed!" message is shown.

Accessing Your Map Image Microservice

Consider the following script in an HTML client:

 let lat = 33.41808, lng = -111.9343, gatewayID = "your-gateway-id", 
api = "execute-api.us-east-1.amazonaws.com/Stage/mapimage?", width = 600, 
height = 480, zoom = 11, 
url =`https://${gatewayID}.${api}c=${lat},${lng}&w=${width}&h=${height}&z=${zoom}
`; fetch(url) .then(response => response.json()) .then(response => 
     { document.getElementById("mapImage").src = 
       `data:image/jpeg;base64,${response}`; }, 
         error => { console.log(error); }); 


The above script calls a constructed URL which points to the new microservice via Amazon API Gateway. You must replace the value of gatewayID with the value generated from your API Gateway when the MapImage app was deployed.

After the fetch completes, it passes the data into an img element with the ID of the map image and sets the source to the response - ensuring it is of type data: image/jpeg;base64.

Sample files are provided at our GitHub. Also, please enjoy our recorded session on this topic here:


Further Reading

Crisp View of Context Map

Microservices Mindmap [Infographic]

Quick Guide to Microservices With Kubernetes, Spring Boot 2.0, and Docker

Topics:
microservices ,mapimage ,image ,serverless ,serverless applications ,aws ,amazon web service

Published at DZone with permission of Michael Palermo , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}