Create Your Own Map Image Microservice
Find out how to create a Map Image with microservice by deploying the HERE MapImage serverless app, AWS.
Join the DZone community and get the full member experience.
Join For FreeMap 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.
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.
Once the landing page for the MapImage application is shown, enter your HERE credentials in the highlighted areas shown below, then deploy.
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
Microservices Mindmap [Infographic]
Quick Guide to Microservices With Kubernetes, Spring Boot 2.0, and Docker
Published at DZone with permission of Michael Palermo, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
How to Handle Secrets in Kubernetes
-
Measuring Service Performance: The Whys and Hows
-
How To Use the Node Docker Official Image
-
Building and Deploying Microservices With Spring Boot and Docker
Comments