Class WebMapProvider
- All Implemented Interfaces:
MapProvider
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}.
-
Field Summary
Fields inherited from interface MapProvider
MAP_TYPE_HYBRID, MAP_TYPE_SATELLITE, MAP_TYPE_STANDARD, MAP_TYPE_TERRAIN -
Constructor Summary
ConstructorsConstructorDescriptionWebMapProvider(String id, String apiKey, String htmlTemplate) Creates a web provider. -
Method Summary
Modifier and TypeMethodDescriptionlongaddCircle(int mapId, double lat, double lon, double radiusMeters, int fillColor, int strokeColor, int strokeWidth) Adds a geodesic circle and returns its element key.longaddMarker(int mapId, byte[] icon, double lat, double lon, String title, String snippet, float anchorU, float anchorV) Adds a marker.voidaddToPath(int mapId, long pathId, double lat, double lon) longbeginPath(int mapId) Starts accumulating a path; feed it withMapProvider.addToPath(int, long, double, double).voidcalcLatLongPosition(int mapId, int x, int y) voidcalcScreenPosition(int mapId, double lat, double lon) createPeer(NativeMap host, int mapId) Creates the view for the map identified bymapId.voiddeinitialize(int mapId) Releases native resources formapIdwhen the map is no longer used.longfinishPolygon(int mapId, long pathId, int fillColor, int strokeColor, int strokeWidth) Finishes the path as a filled polygon and returns its element key.longfinishPolyline(int mapId, long pathId, int strokeColor, int strokeWidth) Finishes the path as a stroked polyline and returns its element key.getId()A stable identifier for this provider, e.g.doublegetLatitude(int mapId) doublegetLongitude(int mapId) floatgetMaxZoom(int mapId) floatgetMinZoom(int mapId) doublegetScreenLat(int mapId) doublegetScreenLon(int mapId) intgetScreenX(int mapId) intgetScreenY(int mapId) floatgetZoom(int mapId) static WebMapProviderA Google Maps JavaScript SDK provider for the given API key (the key must have the Maps JavaScript API enabled).booleanWhether this provider can render on the current device right now (e.g. Google checks that Play Services is present).voidremoveAllElements(int mapId) voidremoveElement(int mapId, long elementId) voidsetCamera(int mapId, double lat, double lon, float zoom, float bearing, float tilt) Moves the camera.voidsetMapType(int mapId, int type) voidsetRotateGestureEnabled(int mapId, boolean enabled) voidsetShowMyLocation(int mapId, boolean show)
-
Constructor Details
-
WebMapProvider
Creates a web provider.
Parameters
-
id: the provider id used in the fallback chain (e.g."web") -
apiKey: the SDK key substituted for{key}(may be empty for keyless SDKs) -
htmlTemplate: a full HTML document with{key}/{lat}/{lon}/{zoom}tokens
-
-
-
Method Details
-
google
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 assetProviderOrder("google", "web", "vector"), rather than colliding with it. -
getId
A stable identifier for this provider, e.g."apple"or"google".- Specified by:
getIdin interfaceMapProvider
-
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 falseNativeMapfalls back to the vector engine.- Specified by:
isAvailablein interfaceMapProvider
-
createPeer
Creates the view for the map identified bymapId. Native providers return aPeerComponentwrapping the native map view; a web-SDK provider returns aBrowserComponent. Either way it is aComponenttheNativeMapadds to its layout. Returningnulltriggers the vector fallback.- Specified by:
createPeerin interfaceMapProvider
-
deinitialize
public void deinitialize(int mapId) Releases native resources formapIdwhen the map is no longer used.- Specified by:
deinitializein interfaceMapProvider
-
setCamera
public void setCamera(int mapId, double lat, double lon, float zoom, float bearing, float tilt) Moves the camera.bearingandtiltare in degrees; providers that do not support them ignore those arguments.- Specified by:
setCamerain interfaceMapProvider
-
addMarker
public long addMarker(int mapId, byte[] icon, double lat, double lon, String title, String snippet, float anchorU, float anchorV) Adds a marker.iconis PNG bytes (ornullfor the default pin); returns an opaque element key.anchorU/anchorVare normalized.- Specified by:
addMarkerin interfaceMapProvider
-
setMapType
public void setMapType(int mapId, int type) - Specified by:
setMapTypein interfaceMapProvider
-
getLatitude
public double getLatitude(int mapId) - Specified by:
getLatitudein interfaceMapProvider
-
getLongitude
public double getLongitude(int mapId) - Specified by:
getLongitudein interfaceMapProvider
-
getZoom
public float getZoom(int mapId) - Specified by:
getZoomin interfaceMapProvider
-
getMaxZoom
public float getMaxZoom(int mapId) - Specified by:
getMaxZoomin interfaceMapProvider
-
getMinZoom
public float getMinZoom(int mapId) - Specified by:
getMinZoomin interfaceMapProvider
-
beginPath
public long beginPath(int mapId) Starts accumulating a path; feed it withMapProvider.addToPath(int, long, double, double).- Specified by:
beginPathin interfaceMapProvider
-
addToPath
public void addToPath(int mapId, long pathId, double lat, double lon) - Specified by:
addToPathin interfaceMapProvider
-
finishPolyline
public long finishPolyline(int mapId, long pathId, int strokeColor, int strokeWidth) Finishes the path as a stroked polyline and returns its element key.- Specified by:
finishPolylinein interfaceMapProvider
-
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.- Specified by:
finishPolygonin interfaceMapProvider
-
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.- Specified by:
addCirclein interfaceMapProvider
-
removeElement
public void removeElement(int mapId, long elementId) - Specified by:
removeElementin interfaceMapProvider
-
removeAllElements
public void removeAllElements(int mapId) - Specified by:
removeAllElementsin interfaceMapProvider
-
calcScreenPosition
public void calcScreenPosition(int mapId, double lat, double lon) - Specified by:
calcScreenPositionin interfaceMapProvider
-
getScreenX
public int getScreenX(int mapId) - Specified by:
getScreenXin interfaceMapProvider
-
getScreenY
public int getScreenY(int mapId) - Specified by:
getScreenYin interfaceMapProvider
-
calcLatLongPosition
public void calcLatLongPosition(int mapId, int x, int y) - Specified by:
calcLatLongPositionin interfaceMapProvider
-
getScreenLat
public double getScreenLat(int mapId) - Specified by:
getScreenLatin interfaceMapProvider
-
getScreenLon
public double getScreenLon(int mapId) - Specified by:
getScreenLonin interfaceMapProvider
-
setShowMyLocation
public void setShowMyLocation(int mapId, boolean show) - Specified by:
setShowMyLocationin interfaceMapProvider
-
setRotateGestureEnabled
public void setRotateGestureEnabled(int mapId, boolean enabled) - Specified by:
setRotateGestureEnabledin interfaceMapProvider
-