@robono/location-web
v0.4.0
Published
Run `npx --package @robono/server robono-messenger-install` in your app and follow the [hosted setup guide](https://robono.com/guides/hosted-messenger.html). Choose Maps in **Features & preview**, including whether it appears as a separate page, inside Me
Readme
Robono Maps for websites
Recommended hosted setup
Run npx --package @robono/server robono-messenger-install in your app and follow
the hosted setup guide. Choose
Maps in Features & preview, including whether it appears as a separate page,
inside Messenger, or both. The supplied Messenger connects it automatically.
Robono runs the location service; your existing server verifies sign-in and sets
who may share with whom. No separate customer location server is required.
For your own separate Maps route, use the same hosted sign-in connection:
import {connectHostedRobono, hostedRobonoTokenProvider} from '@robono/messaging';
import {createBrowserMaps, RobonoMaps} from '@robono/location-web';
// Create once after sign-in, outside React render.
const connection = await connectHostedRobono({
userId: session.userId,
tokenProvider: hostedRobonoTokenProvider({
tokenEndpoint: '/api/robono-token',
getAccessToken: () => session.getAccessToken(),
}),
});
const maps = createBrowserMaps(connection);
<RobonoMaps workspace={maps.workspace} contacts={contacts} />
// Stop sharing before revoking the session on sign-out.
try { await maps.signOut(); }
finally { await connection.signOut(); }If Messenger and Maps share one connection, keep that connection alive while
either screen needs it. Sign out both screens before revoking it. contacts
contains your own authorized names and avatars; it does not grant access.
Optional customer-hosted forwarding connection
For a separate Maps page, use the supplied RobonoMaps screen. It includes the
share list, timed sharing, stop, directions, history and area controls. It uses
the same signed-in route as Messenger; customers do not assemble GPS watchers,
map keys or update loops.
import {createBrowserMaps, RobonoMaps} from '@robono/location-web';
// Create once for the signed-in account, outside React render.
const maps = createBrowserMaps({
endpoint: '/api/robono',
userId: session.userId,
getAccessToken: () => session.getAccessToken(),
});
// Render inside a container with a height:
<RobonoMaps workspace={maps.workspace} contacts={contacts} />
// Before revoking the account's session:
await maps.signOut();Use createRobonoMessengerServer on the server and authorize location.*
operations using the current account and location permissions. Configure who may
share with whom through messenger.location.setGrant; that eligibility does not
start sharing. The supplied screen waits for the user to choose Share.
When using mountRobonoMessenger, Maps and chat tracking connect automatically.
Choose Maps → Placement in Features & preview: separate page, inside chat,
or both. The main menu opens the separate page when selected. A chat address has
its own 15-minute tracking share; forwarding the address creates a separate share.
Register the exact HTTPS website origin in Robono's Maps setup. Robono supplies restricted map access; no Google or LocationIQ account is required. A map load is recorded only when the provider map loads, not when a settings page opens.
Browser live sharing stops when the page is hidden. Browser movement sensing is
available only on devices/browsers that expose motion sensors and grant access.
No GPS is started just to browse the directory. Stale positions are hidden;
an offline person can still stop their own capture. Await signOut() before
ending authentication; dispose() releases the screen's resources.
Existing custom interfaces
Choose GoogleMap, LocationScreen and LocationMessage, or keep your existing interface. Robono issues map access restricted to your registered website. Customers do not need their own provider accounts.
<LocationScreen
settings={settings} name={contact.name}
map={<ManagedMap client={maps.workspace.client}>{(accessKey, onLoad) =>
<GoogleMap accessKey={accessKey} center={position}
markers={[{id: contact.id, label: contact.name, position}]}
onLoad={onLoad} />
}</ManagedMap>}
position={position} status={view.status}
sharing={isSharing} expiresAt={view.expiresAt}
onShare={startAuthorizedSharing}
onStop={stopSharing}
onDirections={openDirections}
onAreas={openAreaEditor}
onHistory={openHistory}
/>All callbacks belong to the integrating app and must operate through its authenticated backend. The screen does not silently start GPS or grant access. Read settings from the service. Clear map markers when a share expires or permission is withdrawn. Preserve Google map controls/attribution and the attribution supplied with address/route data.
A LocationMessage contains an authorized share reference in your conversation. Fetch the current state on opening it; avoid storing coordinates in a permanent chat message. Stop/expiry should leave an “ended” card with no current position.
Interface language
Pass interfaceLocale={{locale:'es'}} to RobonoMaps or LocationScreen.
RobonoLocationLocaleProvider applies the same language to individual Maps
components. 23 interface languages are supplied; custom messages, plurals and
direction work like the Messenger. Names, addresses and provider labels are not
rewritten. See the language guide.
Routes with several stops
Use client.planRoute(stops, {optimize: true}) for 2–25 stops with a fixed start and finish. The web and phone UI packages supply RobonoRoutePlanner using the same authenticated Maps client and existing directions spending controls. Supply your business stop names and coordinates; no additional provider key is needed. Setup, UI options, usage and limitations.
