Skip to main content
GuidesAPI ReferenceExamples

Switch from Google Maps to Magic Lane Platform

Estimated reading time: 3 minutes

In this guide you will learn how to switch from a simple map display using Google Maps JavaScript API to using Magic Lane JavaScript API.

Google Maps

To display a simple map using the Google Maps JavaScript API you would initialize it similarly to this example code from Google Simple Map

let map;

function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: { lat: 48.207, lng: 16.371 },
zoom: 8,
});
}

Magic Lane Maps

The first step is to set your API key token gem.core.App.token, which you can get at the Magic Lane website, see the Getting Started tutorial.
You only need to type your email address and create a new password.

To display a simple interactive map using the Magic Lane JavaScript API you would initialize it similarly to the following example code:

// Start by setting your token from https://developer.magiclane.com/api/projects
gem.core.App.token="your_API_key_token";

let defaultAppScreen = gem.core.App.initAppScreen(
{
container: "map-canvas",
center: [48.207, 16.371, 0], // lat, lon, altitude
zoom: 8
}
);

See the example fullscreen

The map is interactive and supports pan and zoom.

JavaScript Examples

Maps SDK for JavaScript Examples can be downloaded or cloned with Git