# Class MapProviderRegistry

java.lang.Object
com.codename1.maps.spi.MapProviderRegistry

public final class MapProviderRegistry extends Object

The registry through which build-injected `MapProvider` implementations advertise themselves to the core `NativeMap` component.

Core never registers a provider itself. The build, when a `maps.provider` hint selects one, injects the provider implementation into the app and weaves a `register(...)` call into the generated startup code (the same way optional features such as push messaging are wired in). With no provider injected the registry is empty and `NativeMap` renders the vector fallback.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static MapProvider`
  `getProvider()`
  Returns the provider that should back a new native map by walking the configured fallback chain (preferred ids first, honoring a `vector` terminator), then any remaining available provider, or `null` when none can render right now (the caller then uses the vector fallback).
  `static boolean`
  `hasProvider()`
  Whether any registered provider can render on this device right now.
  `static void`
  `register(MapProvider provider)`
  Registers a provider.
  `static void`
  `setPreferredProvider(String id)`
  Hints which single provider id to prefer (then any available).
  `static void`
  `setProviderOrder(String[] ids)`
  Sets the ordered provider fallback chain by id, e.g.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### register

    public static void register(MapProvider provider)
    Registers a provider. Called by build-injected startup code. Repeated registration of the same provider id replaces the earlier instance.

  - ### setProviderOrder

    public static void setProviderOrder(String[] ids)
    Sets the ordered provider fallback chain by id, e.g. `setProviderOrder("google", "huawei", "web")` to try Google Maps, then Huawei Map Kit, then a web-SDK map, before the pure-vector fallback. The special ids `"vector"`/`"none"` terminate the chain (force the vector fallback even if a later provider is available). Any provider not named in a non-terminated chain is still used as a last resort if available. Build hints (`maps.providers` / per-platform `<platform>.maps.providers`) set this at startup; call it from app code to override.

  - ### setPreferredProvider

    public static void setPreferredProvider(String id)
    Hints which single provider id to prefer (then any available). Kept for convenience; equivalent to a one-element [#setProviderOrder(String[])].

  - ### getProvider

    public static MapProvider getProvider()
    Returns the provider that should back a new native map by walking the configured fallback chain (preferred ids first, honoring a `vector` terminator), then any remaining available provider, or `null` when none can render right now (the caller then uses the vector fallback).

  - ### hasProvider

    public static boolean hasProvider()
    Whether any registered provider can render on this device right now.