A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/maps/documentation/javascript/map-ids/get-map-id below:

How to create map IDs | Maps JavaScript API

Skip to main content How to create map IDs

Stay organized with collections Save and categorize content based on your preferences.

Paid feature: Features accessed by adding a map ID triggers a map load charged against the Dynamic Maps SKU for Android and iOS. See Google Maps Billing for more information.

A map ID is a unique identifier that represents Google Map styling and configuration settings that are stored in Google Cloud. You use map IDs to enable features or manage or style maps on your websites and in your applications. You can create map IDs for each platform you need--JavaScript, Android, iOS, or Static maps--in your Google Cloud console project on the Map Management page.

For more details and features that use map IDs, see Map ID overview.

Required permissions

To create or manage any map IDs in your project, you must use a principal with the appropriate role-level permissions, Editor or Owner, on the Cloud console IAM page for the project. For details, see IAM basic and predefined roles reference.

Create map IDs

Create map IDs in the Cloud console following these steps:

  1. Sign in to and open a Cloud console project with the required permissions.

  2. In the Cloud console, go to the Maps Management page.

  3. Click Create map ID.

  4. On the Create new map ID page, do the following:

    1. For Name, give the map ID a name.
    2. Optional: For Description, describe what the map ID is used for.
    3. For Map type, select the platform on which you plan to use the map ID. If you choose JavaScript, also choose a Raster (the default) or Vector map type. For more information on vector maps, see Vector Maps.
    4. Click Save to show your new map ID.
Associate a map ID to a map style

If you are using cloud-based maps styling, you associate a map style with your map ID. For details, see Associate your style to a map ID.

Add the map ID to your app Android

Add your map ID through a <fragment> element in the activity's layout file, by using the MapView class, or programmatically using the GoogleMapOptions class.

For example, assume you created a map ID that is stored as a string value named map_id in res/values/strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="map_id">MAP_ID</string>
</resources>

For maps added through a <fragment> element in the activity's layout file, all map fragments that should have the custom style must specify the map ID in the map:mapId attribute:

<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
    map:name="com.google.android.gms.maps.SupportMapFragment"
        map:mapId="@string/map_id" />

You can also use the map:mapId attribute of the MapView class to specify a map ID:

<com.google.android.gms.maps.MapView
    xmlns:map="http://schemas.android.com/apk/res-auto"
    ....
    map:mapId="@string/map_id" />

To specify a map ID programmatically, pass it to a MapFragment instance using the GoogleMapOptions class:

Java
 MapFragment mapFragment = MapFragment.newInstance(
     new GoogleMapOptions()
         .mapId(getResources().getString(R.string.map_id)));
Kotlin
 val mapFragment = MapFragment.newInstance(
     GoogleMapOptions()
         .mapId(resources.getString(R.string.map_id))
 )

In Android Studio, build and run your app as you normally would. Custom styles configured in the first step are applied to all maps with the specified map ID.

iOS

To instantiate a map using a map ID, do the following:

  1. Create a GMSMapID with the map ID string from Cloud console.
  2. Create a GMSMapView specifying the map ID you just created.
Swift
let camera = GMSCameraPosition(latitude: 47.0169, longitude: -122.336471, zoom: 12)
let mapID = GMSMapID(identifier: "MAP_ID")
let mapView = GMSMapView(frame: .zero, mapID: mapID, camera: camera)
self.view = mapView
Objective-C
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:47.0169
                                                        longitude:-122.336471
                                                             zoom:12];
GMSMapID *mapID = [GMSMapID mapIDWithIdentifier:@"MAP_ID"];
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero mapID:mapID camera:camera];
self.view = mapView;

If you are using your own map ID, you can set your map ID in the Cloud console to have a new style at any time, and that style will be reflected on your map view automatically for you and users within about six hours.

If you want to see the changes immediately, you can close out and restart your app by exiting the app, forcing a quit of the app from the recently-used apps list, and then reopening it. The updated map will then be visible.

JavaScript

To create a map with a map ID in your application code:

  1. If you are already customizing your map with embedded JSON code, remove the styles property from your MapOptions object; otherwise, skip this step.

  2. Add a map ID to the map using the mapId property. For example:

map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8,
mapId: 'MAP_ID'
});
Maps Static

To add a map ID to a new or existing map that uses one of our web-service APIs, append the map_id URL parameter and set it to your map ID. This example shows adding a map ID to a map using Maps Static API.

<img src="https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Clabel:C%7C40.718217,-73.998284&key=YOUR_API_KEY&map_id=MAP_ID&signature=YOUR_SIGNATURE" />

If you have a digital signature in your Maps Static URL before adding your map ID, you will need to

create and add a new digital signature

after adding your map ID. When generating your new URL signing secret, remember to remove your previous digital signature from the URL.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-15 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-15 UTC."],[[["A map ID is a unique identifier that represents a single Google Map instance, used to manage, style, or enable features on maps across various platforms (JavaScript, Android, iOS, Static Maps)."],["Map IDs are created within the Google Cloud console on the Map Management page, requiring Editor or Owner permissions."],["To use a map ID, you need to integrate it into your application code based on the specific platform (JavaScript, Android, iOS, or Static Maps) you're working with, following the provided instructions."],["Cloud-based map styling allows you to associate a style with your map ID, impacting its visual appearance on the map."],["Map IDs can be added to the Maps Static API by appending the 'map_id' URL parameter, and a new digital signature might be required for existing URLs."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4