[PLUGIN] - Google Maps (native mobile)

Hi all,

Native Google Maps plugin available with a ton of features in it. It’s been provisionally made available but it’s still very much in development and they’ll be more to add over the next few weeks. It’s an extensive, well documented plugin with a lot of thought and effort put into it.

The editor link along with the instructions/documentation, can be seen here:
Please note this is a native plugin so you won’t be able to view it directly through the browser, you’ll need to use the BubbleGo app once it’s installed.
https://bubble.io/page?id=paul-testing-4&tab=Design&name=Home&type=page

The plugin link is here:
https://bubble.io/plugin/google-maps-native-mobile-1780913784036x145550589994729470


As of current, the details are as follows:

So, this a real Google map for native mobile apps, drawn by the device itself rather than in a web view, so it stays fast and smooth even when tilted and rotated. The same Google map on both iOS and Android, with markers, drawing tools, buffer zones, and full GeoJSON, KML and WMS layer support.

Everything that happens on the map comes back in states, so things like the camera view, the visible area, taps and long-presses, selected features, full lists of markers, shapes and loaded features etc. The map is drawn natively by the device rather than inside a web view.

The map

  • Native Google Maps on iOS and Android (through react-native-maps), not Apple Maps on iPhones.
  • A full camera model: centre, zoom, heading (rotation) and pitch (tilt), reported back live.
  • Choose the map type: standard, satellite, hybrid or terrain.
  • Apply your own custom map styling (JSON) to restyle roads, water, labels and more.
  • Toggle each gesture independently: zoom, scroll, rotate and tilt.
  • Set minimum and maximum zoom limits to keep users within a sensible range.
  • Optional overlays: user location, my-location button, compass, scale, 3D buildings, live traffic, indoor maps and points of interest.
  • Map padding on each side, so controls and overlays sit clear of your own interface.
  • Taps, long-presses and the visible bounding box all exposed to your workflows.
  • Set camera action to glide the view to any position, zoom, rotation or tilt.

Markers and shapes

  • Add markers and shapes (polygons, polylines, rectangles, circles) from your data in one action.
  • Custom marker icons, labels, colours, draggable markers, and tappable popovers.
  • Per-shape fill, stroke and width, with a separate selected style.
  • Update or remove any marker or shape by id without rebuilding the map.
  • Markers-in-shapes detection: know which markers fall inside which areas.

Drawing tools

  • An optional on-map toolbar so users can draw markers, lines, rectangles, circles and polygons by hand.
  • Tap to place, drag handles to reshape, with single-step undo.
  • Choose the toolbar position, and show or hide the colour palette, delete button and marker icon.
  • Every drawn feature is reported to your workflows with its coordinates.

Buffer areas

  • Generate a buffer zone a set distance around any shape, for catchment and contingency areas.
  • Polygons get a rounded buffer; circles get a concentric circle.
  • Each buffer carries its own area and perimeter measurements.

GeoJSON and KML layers

  • Load GeoJSON or KML onto the map from a URL or pasted text, as a removable layer.
  • Style every feature uniformly, or drive fill, stroke and width from feature properties with conditions (for example, colour by population).
  • KML files keep their own embedded styles by default, which you can selectively override.
  • Tappable features with property-substituted popovers, published to a single typed layers list.
  • Performance controls for large files: feature caps, geometry simplification, and display-only modes.

WMS and tile layers:

  • Load a WMS service as a map overlay, with control over layers, version, styles, projection, format and opacity.
  • Tap the map to query a WMS layer (GetFeatureInfo) and read the response back in a state, with optional content filtering.
  • Load generic XYZ/TMS tile sources from a URL template, for open tile providers and custom basemaps.
  • For WFS services, point the Load GeoJSON action at your GetFeature URL, since the response is GeoJSON.
  • One Remove layer action handles every format, by layer, by feature, or all at once.

Data and output

  • All map data exposed as typed states that drop straight into repeating groups and elements.
  • Coordinates provided in several formats so they round-trip cleanly back into the plugin.
  • Fit to bounds, clear map, and full selection handling included.
  • Debug log you can copy for troubleshooting.

In development

This plugin is an active, working project that is being added to over time. Everything described
above is built and working. Features still planned include:

  • Exporting layers.
  • Checking for intersections between shapes.
  • Marker clustering for large numbers of markers.
  • Map address search element.
  • Live dynamic markers and shapes.
  • Plus a few more things in the pipeline.

Paul

New features added, all are configurable.

  • GeoJSON and shape intersection.
    The Layers state contains all data loaded from GeoJSON, KML, and WMS sources. When a shape is drawn on the map and intersects with features from any supported layer, the IDs of those shapes are automatically added to the intersecting_shape_ids field.

    There’s also a new setting called Features above shapes that will allow you to visually change the stacking behaviour (not seen in the above screenshot!)

  • Marker clustering
    Full support for marker clustering now included with a bunch of options you can use to control styling and basic features.

  • Tooltips for the drawing tools UI (to aid with mobile functionality)
    Sometimes it might be useful to have some tooltips appear instructing users how to interact with the map in regards to how shapes are drawn using finger movements. These tooltips can be switched on using the relevant options. There’s a slightly different instruction depending on icon selected.

well done man. much needed

Thanks @adig

Live marker/shape functionality has also been included, so now data that changes in your database will automatically be reflected on the map.

This is just an alternative way to load markers/shapes, as previously you would have had to run the corresponding Create markers or Create shapes action which sets markers/shapes as static objects on the map.

There are two new options that control this, shown below. The documentation explains how it works in further detail, but essentially a JSON object is passed using the :format as text operator and it reads the data from there. When the data changes, the object updates which then makes the changes on the map.

They’ll be a built in address search element coming soon.

Paul

Last update:

The search address bar has been included as a separate component that looks like the image below. It has plenty of options available available, both functional and styling.

The search element requires your Google API key supplied in the plugin options and it needs to have access to the Places (new) API.

Paul

The ‘Nearby places’ functionality has been built into the ‘Search component’ and there’s a quick video below showing hotels plotted around a given radius (1.5km) around a selected place and then plotted onto the map.

Here is the entire documentation for the autocomplete element along with all options, states, events and explanations on how everything works.

Connection and appearance

Setting Description
Target map id The Map id of the map this search controls. Must match the map’s Map id.
Placeholder text The grey hint shown in the empty box.

What the search returns

Setting Description
Country restriction Limit results to one or more countries, as two-letter codes (for example GB, or GB,FR). Leave blank for no restriction.
Language code Preferred language for results (for example en). Leave blank to use the device default.
Type filter Limit results to certain place types (for example locality, or street_address). Leave blank for all types.
Region code Optional two-letter code (for example GB) that influences address formatting and result ranking. This does not filter results to that country: use Country restriction for that.
Query predictions When on, plain search-term suggestions (such as “pizza near me”) appear alongside real places. These are not places, so tapping one only fills the box; it does not move the map. Off by default.

Typing and the predictions list

Setting Description
Minimum characters How many characters must be typed before predictions are fetched. Default 3.
Debounce (ms) How long to wait after typing stops before fetching predictions. Default 300.
Auto-hide keyboard On a phone, the first tap on a result usually just closes the keyboard, so it takes two taps to select. Turn this on to have the keyboard hide itself shortly after results appear, so a single tap then selects. Off by default (the keyboard stays, two taps to select).
Auto-hide delay (ms) When Auto-hide keyboard is on, how long after the results settle before the keyboard hides. The timer restarts each time the results refresh, so it only hides once the user has stopped typing. Default 800.

Search area

Setting Description
Search area mode How to focus the search geographically. Off (the default) biases results towards wherever the map is currently centred. Bias prefers places near the search area but still allows others. Restrict is a hard filter: places outside the area are never shown. Google allows one or the other, never both, which is why this is a single choice.
Search area latitude The centre of the search area, used when the mode is Bias or Restrict. Ignored when the mode is Off.
Search area longitude The other half of the search area centre. Set this together with the latitude.
Search area radius m How far the search area reaches, in metres. A radius is required: Google ignores the centre without one, so 50000 (50km) is used if you leave this blank.

Distance

Setting Description
Distance from lat Optional. The latitude to measure distances from. When set with its longitude, the chosen place’s distance appears in the Selected distance m state.
Distance from lng Optional. The longitude to measure distances from. Set this together with Distance from lat, as distances are only calculated when both are given.

When a place is chosen

Setting Description
Result zoom The zoom level the map uses when moving to a chosen place. Leave blank to use the place’s own recommended view.
Place marker When on, a single marker is dropped on the map at the chosen place. Choosing another place moves that same marker (there is never more than one), and clearing the search box removes it. Off by default.

Nearby places

Setting Description
Nearby places When on, choosing a place also looks for places around it (hotels, restaurants, and so on) and publishes them as a list. Off by default.
Nearby types The kinds of place to look for, such as hotel, or restaurant,cafe for both. Must be Google place types; the full list is at Place Types (New)  |  Places API  |  Google for Developers . Capitals, spaces and plurals are tidied up for you (Hotels becomes hotel), but a word Google does not recognise is reported as an error. Only used when Nearby places is on.
Nearby exclude types Any kinds of place to leave out of the results. Leave blank to exclude nothing.
Nearby radius m How far around the chosen place to look, in metres. Defaults to 1500 (1.5km). The furthest Google allows is 50000 (50km).
Nearby max results How many places to return, from 1 to 20. Defaults to 20. Asking for fewer does not cost less, so there is no saving in lowering it.
Nearby rank by How the results are ordered. Distance puts the nearest first, which suits “what is close to me” lists. Popularity is Google’s own ordering and is the default.
Nearby markers When on (the default), each place found is plotted on the map. Searching again replaces them, and clearing the search box removes them.
Nearby fit bounds When on, the map zooms out to frame every place found rather than staying on the searched place. Off by default.

Styling options

The search element has its own styling section so you can match it to your app:

Field What it does
Box background The fill of the search box.
Box border radius How rounded the box corners are.
Box border colour The box border colour.
Box border width The box border thickness.
Text colour The colour of the typed text.
Placeholder colour The colour of the placeholder hint.
Font size The size of the typed text.
Box vertical padding The space above and below the text inside the box. Increase it to make the search box taller, decrease it to make it shorter.
List background The fill of the predictions dropdown.
List border colour The border of the predictions dropdown.
Prediction primary The colour of each prediction’s main line.
Prediction secondary The colour of each prediction’s smaller second line.
Prediction divider The colour of the thin line between predictions.
Spinner colour The colour of the loading spinner shown while searching.

States

The Google Map Search element publishes the chosen place, so you react to a search on this element (not the map):

The chosen place

State Description
Selected latitude The latitude of the place the user chose.
Selected longitude The longitude of the place the user chose.
Selected name The name of the chosen place (for example “Empire State Building”).
Selected address The full formatted address of the chosen place.
Selected place id Google’s unique Place ID for the chosen place. Useful if you want to look the place up again or store a stable reference to it.
Selected distance m How far the chosen place is, in metres, from the point set in Distance from lat and Distance from lng. Blank unless both of those are set.

The chosen place’s viewport

State Description
Selected viewport NE latitude The north-east corner latitude of the place’s recommended viewport (blank if the place has no viewport).
Selected viewport NE longitude The north-east corner longitude of the place’s recommended viewport.
Selected viewport SW latitude The south-west corner latitude of the place’s recommended viewport.
Selected viewport SW longitude The south-west corner longitude of the place’s recommended viewport.

Nearby places

State Description
Nearby places The list of places found around the chosen place, when Nearby places is on. Each one carries its name, address, coordinates, types and Google’s suggested icon. Empty when the feature is off or nothing was found.

Diagnostics

State Description
Error A message describing the last search problem (for example a missing key or no network). Empty when all is well.
Debug logs Diagnostic text describing what the search element did (requests, selections, errors). Useful for troubleshooting; you can bind it to a text element while testing.

Events.

Event When it fires
Place selected When the user chooses a place from the predictions and the map is moved to it.
Nearby places found When the nearby results have arrived and any markers have been placed. Use this to show your list. Only fires when Nearby places is on.
Error occurred When a search fails, for example a missing or invalid API key, or no network. The Error state holds the message.

If you need to react only once the map has finished moving (rather than the instant a place is chosen), use the map’s own Region changed event.

Notes. The map does not need any special setup beyond its Map id; it watches the channel and moves itself. You can have several maps and several search boxes on one page; just give each map a unique Map id and point each search box at the one it should control.

Focusing the search on an area. By default (Search area mode set to Off) predictions are biased towards the target map’s current centre when it is available, so results near the visible area rank higher. If the map has not reported a centre yet, Google falls back to guessing roughly where the device is. Set the mode to Bias or Restrict when you want to control this yourself:

  • Bias means “prefer this area”. Places near the centre you give rank higher, but somewhere further away can still appear if it matches well. Use this when you want helpful local results without ruling anything out.
  • Restrict means “only this area”. Anything outside the radius is never returned. Use this when the search genuinely must not offer places elsewhere, such as picking a site within a delivery zone.

Both need a centre (Search area latitude and longitude) and a radius in metres. If you leave the radius blank, 50km is used, because Google ignores the centre entirely when no radius is given.

Showing how far away a place is. Set Distance from lat and Distance from lng to the point you want to measure from, often the user’s location or a fixed depot. The chosen place’s distance in metres then appears in the Selected distance m state. This is measured by Google as part of the search, so it costs nothing extra and needs no calculation on your side. Leave the two fields blank if you do not need distances.

Finding places around the searched place. Turn on Nearby places and the search does a second job: once the user picks a place, it looks for places of the kinds you chose around that spot. Searching “Bournemouth” with Nearby types set to lodging moves the map to Bournemouth and finds the hotels there.

The kinds of place come from the Nearby types setting, not from what the user types. Google’s nearby search takes a type, not a phrase, so the user searches for a location and you decide what to look for around it. A user cannot type “hotels” into the box and have this work: they type where, you configure what.

Choosing the types. These are Google’s own place types, not free wording, so “hotel” works and “places to stay” does not. The full list is here:

https://developers.google.com/maps/documentation/places/web-service/place-types

Use the types from Table A on that page. The plugin tidies up the most common slips for you, so capitals, spaces and plurals are all handled: “Hotels” becomes hotel, “Tourist Attractions” becomes tourist_attraction. It only does this when it is certain, so a real type is never altered. If you use a word Google does not recognise at all, the search reports an error naming it, and the Error state holds the message.

The results arrive in two forms. The Nearby places state holds the full list, each with its name, address, coordinates, types and Google’s suggested icon, ready to show in a repeating group. At the same time, unless you turn Nearby markers off, each one is plotted on the map. Searching again replaces the previous set, and clearing the search box removes them, so they never pile up. Use the Nearby places found event to know when the list is ready.

Two things worth knowing. Each completed search with this feature on makes two calls to Google rather than one, so leave it off unless an app needs it. And the results are Google’s places, not your own records: if you want to show your own listings, use the chosen place’s coordinates from the Selected latitude and Selected longitude states and query your own database with them.

Matching results against your own data. The search element finds places from Google and reports the chosen one’s coordinates. If you want to compare that against addresses held in your own database (for example, “which of my sites are within 5km of the searched address”), that part is done in your app’s own logic using the published Selected latitude and Selected longitude, not by this element. Your stored addresses need coordinates of their own for such a comparison to be possible.