public class WebMapProvider
- Object
- WebMapProvider
ImplementsMapProvider
A cross-platform MapProvider that hosts a JavaScript map SDK (Google Maps
JS, Azure Maps, …) inside a BrowserComponent. Because it relies only on
a web view it renders on every platform that has a browser, which makes it
the natural "web" entry in a provider fallback chain and the only way to
surface SDKs that ship no native component (e.g. Azure Maps).
The map’s initial camera comes from the host NativeMap (its center/zoom),
baked straight into the page so the map opens on the right region without a
follow-up call. Use google(String) for a ready-made Google Maps page, or
the constructor with a custom HTML template containing the tokens
{key}, {lat}, {lon} and {zoom}.
Constructors
public WebMapProvider(String id, String apiKey, String htmlTemplate) | Creates a web provider. |
Methods
Inherited fields
Inherited methods
Constructor details
WebMapProvider
public WebMapProvider(String id, String apiKey, String htmlTemplate)Creates a web provider.
Parameters
idString- the provider id used in the fallback chain (e.g.
"web") apiKeyString- the SDK key substituted for
{key}(may be empty for keyless SDKs) htmlTemplateString- a full HTML document with
{key}/{lat}/{lon}/{zoom}tokens
Method details
public static WebMapProvider google(String apiKey)A Google Maps JavaScript SDK provider for the given API key (the key
must have the Maps JavaScript API enabled). Its id is
"web" – not
"google" – so it slots in as the cross-platform web fallback after
the native "google" provider in a chain such as
setProviderOrder("google", "web", "vector"), rather than colliding
with it.getId
public String getId()A stable identifier for this provider, e.g.
"apple" or "google".isAvailable
public boolean isAvailable()Whether this provider can render on the current device right now
(e.g. Google checks that Play Services is present). When this returns
false
NativeMap falls back to the vector engine.createPeer
public Component createPeer(NativeMap host, int mapId)Creates the view for the map identified by
mapId. Native providers
return a PeerComponent wrapping the native map view;
a web-SDK provider returns a BrowserComponent. Either
way it is a Component the NativeMap adds to its layout. Returning
null triggers the vector fallback.isReady
public boolean isReady(int mapId)Whether the web map for
mapId has finished painting its tiles, i.e. the
SDK has fired its first tilesloaded event. Lets a caller wait for the
real render rather than a fixed delay. Cheap and non-blocking: reads a
Set updated by the one-shot JS->Java readiness bridge in createPeer.deinitialize
public void deinitialize(int mapId)Releases native resources for
mapId when the map is no longer used.setCamera
public void setCamera(int mapId, double lat, double lon, float zoom, float bearing, float tilt)Moves the camera.
bearing and tilt are in degrees; providers that
do not support them ignore those arguments.addMarker
public long addMarker(int mapId, byte[] icon, double lat, double lon, String title, String snippet, float anchorU, float anchorV)Adds a marker.
icon is PNG bytes (or null for the default pin);
returns an opaque element key. anchorU/anchorV are normalized.setMapType
public void setMapType(int mapId, int type)getLatitude
public double getLatitude(int mapId)getLongitude
public double getLongitude(int mapId)getZoom
public float getZoom(int mapId)getMaxZoom
public float getMaxZoom(int mapId)getMinZoom
public float getMinZoom(int mapId)beginPath
public long beginPath(int mapId)Starts accumulating a path; feed it with
addToPath.addToPath
public void addToPath(int mapId, long pathId, double lat, double lon)finishPolyline
public long finishPolyline(int mapId, long pathId, int strokeColor, int strokeWidth)Finishes the path as a stroked polyline and returns its element key.
finishPolygon
public long finishPolygon(int mapId, long pathId, int fillColor, int strokeColor, int strokeWidth)Finishes the path as a filled polygon and returns its element key.
addCircle
public long addCircle(int mapId, double lat, double lon, double radiusMeters, int fillColor, int strokeColor, int strokeWidth)Adds a geodesic circle and returns its element key.
removeElement
public void removeElement(int mapId, long elementId)removeAllElements
public void removeAllElements(int mapId)calcScreenPosition
public void calcScreenPosition(int mapId, double lat, double lon)getScreenX
public int getScreenX(int mapId)getScreenY
public int getScreenY(int mapId)calcLatLongPosition
public void calcLatLongPosition(int mapId, int x, int y)getScreenLat
public double getScreenLat(int mapId)getScreenLon
public double getScreenLon(int mapId)setShowMyLocation
public void setShowMyLocation(int mapId, boolean show)setRotateGestureEnabled
public void setRotateGestureEnabled(int mapId, boolean enabled)