How to embed a custom map in Android?

Asked

Viewed 160 times

0

I have a custom map made on Google maps and want to incorporate it in an Android app. I want you to load the custom map as soon as you enter the app.

  • Your style is in a json?

  • No, it’s on a Google My Maps map, it’s an editable real-time map, I was able to pull it via frame and use it in a webview, I just wanted to know if there’s another way using the Google maps api, but I don’t think.

1 answer

0

You can customize the style of your map using MapStyleOptions through a JSON object in which you can put inside the directory raw. This is defined within the method onMapReady() in his Activity. See below for an example:

@Override
public void onMapReady(GoogleMap googleMap) {
    // Personalizando usando um objeto JSON
    MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(
            this, R.raw.style_json);
    googleMap.setMapStyle(style);
}

For more details you can check the documentation at how to add a stylized map.

Example:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.