Skip to content

Commit 967f258

Browse files
committed
Add Google Maps widget + Place Picker
1 parent 8b7710f commit 967f258

14 files changed

+436
-1
lines changed
96.8 KB
Loading
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: Secure API Keys
3+
---
4+
5+
# Best Practices: Secure API Keys
6+
7+
Google Cloud API key restriction is essential for managing access and enhancing security when
8+
working with Google Cloud services. This overview explains how to effectively restrict API keys,
9+
allowing developers to control how and where their keys can be used. Developers can set geographical
10+
restrictions, bind keys to specific IP addresses, or limit usage to particular services. These
11+
measures ensure that API keys are secured, helping to protect projects and maintain optimal
12+
functionality.
13+
14+
To minimize potential damage from compromised API keys:
15+
16+
- **Add restrictions to your API key:** By setting restrictions, you can limit how an API key can be
17+
used, thus reducing the impact if it becomes compromised.
18+
19+
- **Delete unnecessary API keys:** Remove any API keys that are no longer required to reduce
20+
exposure to attacks.
21+
22+
- **Rotate your API keys periodically:** Regularly create new API keys, delete the old ones, and
23+
update your applications to use the new keys. This practice helps maintain security and limit the
24+
lifespan of any single key.
25+
26+
## Add restrictions to your API key
27+
28+
API keys are unrestricted by default. Unrestricted keys are insecure because they can be used by
29+
anyone, from anywhere. You can add either [**application restrictions
30+
**](https://cloud.google.com/docs/authentication/api-keys?#adding-application-restrictions) or [*
31+
*API restrictions**](https://cloud.google.com/docs/authentication/api-keys?#api_key_restrictions) to
32+
enhance
33+
security.
34+
35+
In the following example, we will use the **Map API keys** and restrict them to specific platforms
36+
using
37+
their unique identifiers.
38+
39+
At this stage, you should already have API keys created, but they are currently unrestricted. If
40+
they are not yet created, you can follow the integration process for any of the Google Cloud
41+
services we support in FlutterFlow, or for Maps, [**you can go here.
42+
**](../maps/google-maps/getting-started)
43+
44+
All your created API keys should be available on
45+
the [Cloud Credentials Page](https://console.cloud.google.com/apis/credentials). (Ensure you are
46+
logged into the correct Google account and are in the right Google Cloud project.)
47+
48+
Follow the steps below to enable the iOS key exclusively for iOS apps with a unique package name:
49+
50+
<div style={{
51+
position: 'relative',
52+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
53+
height: 0,
54+
width: '100%'
55+
}}>
56+
<iframe
57+
src="https://demo.arcade.software/givOcppDSZHXzWJDloWj?embed&show_copy_link=true"
58+
title="Restrict API Keys"
59+
style={{
60+
position: 'absolute',
61+
top: 0,
62+
left: 0,
63+
width: '100%',
64+
height: '100%',
65+
colorScheme: 'light'
66+
}}
67+
frameborder="0"
68+
loading="lazy"
69+
webkitAllowFullScreen
70+
mozAllowFullScreen
71+
allowFullScreen
72+
allow="clipboard-write">
73+
</iframe>
74+
</div>
75+
76+
Now your iOS API Key will only work when accessed from your app with the given unique identifier.
77+
You can also restrict the API keys by **HTTP referrers** or **IP addresses**. Here's a quick
78+
overview from the official docs:
79+
80+
![app-restriction.png](app-restriction.png)
81+
82+
:::note[Learn More]
83+
Learn more about **securing API keys for all platforms and restricting API usage** by visiting
84+
the official [**Google Cloud Docs**](https://cloud.google.com/docs/authentication/api-keys?#securing).
85+
:::
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Google Maps",
3+
"position": 1
4+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Getting Started
3+
sidebar_position: 1
4+
5+
---
6+
7+
# Google Maps
8+
9+
FlutterFlow natively supports Google Maps, providing a seamless and efficient way to embed
10+
interactive maps into your FlutterFlow apps.
11+
12+
## Getting Started
13+
14+
To enable **Google Maps** in your project, please follow the steps:
15+
16+
### Get API Keys
17+
18+
To start working with **Google Maps APIs**, you need to enable the **Maps API** from the [Google
19+
Cloud Console](https://console.cloud.google.com/).
20+
21+
- As you land on the Cloud console, make sure you are in the correct Google Cloud project. Then,
22+
from the right menu, click on [**Library**](https://console.cloud.google.com/apis/library) and
23+
search for **Maps**.
24+
25+
- You may receive a prompt from Google Cloud to add a billing account. Please add a billing account
26+
to continue.
27+
28+
- You will see options such as the **Maps SDK for iOS, Maps SDK for Android**, and the **Maps
29+
Javascript API**. Select the platform you wish to support and then click **Enable**.
30+
If you are running on Run Mode, ensure that your Maps Javascript API is enabled.
31+
32+
<div class="video-container"><iframe src="https://www.loom.
33+
com/embed/b1f6d8ddcc44492a92f833dafa619ec0" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
34+
35+
36+
:::warning
37+
To secure your API keys, refer to the [**Best Practices guide: Secure API Keys
38+
**](..%2F..%2Fcloud%2Frestrict-keys.md)
39+
:::
40+
41+
- Click on the Credentials menu from the left panel.
42+
43+
- Find the key for the platform you need, and copy the key.
44+
45+
### Add keys to FlutterFlow
46+
47+
Now add the API keys platform wise to FlutterFlow Settings page
48+
49+
![g-maps-settings.png](..%2Fimgs%2Fg-maps-settings.png)
50+
51+
### Create a new Key if not available
52+
53+
If you don't find the Android key (auto created by Firebase) or iOS key (auto created by
54+
Firebase) in the Google developer console, here are the steps to create one:
55+
56+
- On your Cloud console, click the **Credentials** menu on the left.
57+
58+
- Click on the **+ Create Credentials** at the top.
59+
60+
- Click on the **API Key** to create a new key for the Android app. Similarly, create one for
61+
iOS and Web.
62+
63+
<div class="video-container"><iframe src="https://www.loom.
64+
com/embed/2c644aa950c44f76b19c6787784cf3b5?sid=3e22206e-4b4b-4734-b842-0c644d32f344" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
65+
66+
67+
68+
69+
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
---
2+
title: Google Maps Widget
3+
sidebar_position: 2
4+
---
5+
6+
# Adding Google Maps widget
7+
8+
The Google Maps widget enables the integration of interactive maps into your app, offering users
9+
valuable geographical insights. For instance, in a food delivery app, this widget could display the
10+
locations of restaurants. It offers a range of customization options, allowing you to tailor the
11+
display with various map types and markers to suit your specific needs.
12+
13+
:::danger[Feature Completion]
14+
As we continuously enhance our platform, please note that while our integration is robust, it is not
15+
yet feature-complete. We encourage you to review the available APIs and features detailed below to
16+
ensure they meet your app development needs before integration.
17+
:::
18+
19+
![google-maps-widget.png](..%2Fimgs%2Fgoogle-maps-widget.png)
20+
21+
:::info[Prerequisite]
22+
Ensure you have added the Google Map API keys before adding the Google Maps widget to your project
23+
:::
24+
25+
## Add Google Map widget
26+
27+
- Open the Widget Palette and locate the **Google Map** widget under the **Base Elements** tab. You
28+
can
29+
drag it to your desired location or add it directly from the widget tree or canvas area.
30+
31+
- By default, the map displays a random location. To set a specific location, go to the
32+
**Properties Panel > Initial Location**.
33+
34+
- Enter the latitude and longitude values in the **Lat and Lng** fields to specify the location. To
35+
use the user's current location, set a variable through the **Set Variable menu > Global
36+
Properties > Current Device Location**.
37+
38+
- To change the map type, go to the **Properties Panel > Map Type** and select one of the following
39+
options:
40+
- **Roadmap:** Displays the default road map view.
41+
- **Terrain:** Shows a physical map based on terrain information.
42+
- **Hybrid:** Combines normal and satellite views.
43+
- **Satellite:** Displays satellite images from Google Earth.
44+
45+
- To customize the visual appearance of your map, navigate to the **Properties Panel > Map Style**.
46+
47+
- To set the **initial zoom level** of the map, go to the **Properties Panel > Initial Zoom** of Map
48+
and
49+
enter the desired value. Note that a higher value will zoom in on the map while a lower value will
50+
zoom out.
51+
52+
<div class="video-container"><iframe src="https://www.loom.
53+
com/embed/11c929da4a82492fb2d9e690779051d8?sid=477a3de8-3f0c-42e1-a8b6-7556c3e72e96" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
54+
55+
<figure>
56+
57+
<figcaption class="centered-caption"></figcaption>
58+
</figure>
59+
:::tip
60+
If you don't see your current location while testing, make sure you have enabled location permission in your browser.
61+
62+
![location-browser.png](..%2Fimgs%2Flocation-browser.png)
63+
:::
64+
65+
## Markers
66+
67+
A marker is an icon that appears over the map, indicating a location. To add markers:
68+
69+
- Select the **Google Map** widget, move to the **Properties Panel > Num Markers** and select
70+
whether you
71+
want to show **Single** or **Multiple** markers.
72+
73+
### Set Markers from Firebase
74+
75+
- Set the Marker Type to **Document** if the data is on Firestore Collection
76+
77+
- Incase of Documents, create a collection and query it on any widget (must be a parent of
78+
GoogleMap) or page.
79+
80+
- In Marker Document, set the source of markers as shown in the following video.
81+
82+
<div class="video-container"><iframe src="https://www.loom.
83+
com/embed/265b96cfd3554ce5b7516650b950b303?sid=83b3f4bd-8470-4307-9cbe-b742681c383f" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
84+
85+
### Set Markers from List of LatLng
86+
87+
If you choose **LatLng**, you must provide a source that contains a list of locations as Data Type
88+
(LatLng) (e.g., App State > [variable_name] (List of **LatLng**)).
89+
90+
<div class="video-container"><iframe src="https://www.loom.
91+
com/embed/e0cf2e67ab0e45b7aedc3bb96b212d73?sid=38a4bdce-89f5-4278-aaa2-4ad8e859f925" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
92+
93+
### Changing Marker Color
94+
95+
To change the marker color, move to the Properties Panel > Google Map > set the Marker Color
96+
dropdown value to the color you like:
97+
![marker-color.png](..%2Fimgs%2Fmarker-color.png)
98+
99+
### Set Marker Image
100+
101+
Custom marker images can enhance your map interface by making it more intuitive and visually
102+
engaging, while also aligning with your app's branding. To set an image as a marker:
103+
104+
- Move to the **Properties Panel > Google Map > set the Marker Icon to Image**.
105+
106+
- Select the type of image you want to set:
107+
- For an image hosted online, set the Image Type to **Network** and specify the image URL in the
108+
Path field.
109+
- To provide an image from your system, set the Image Type to **Asset** and upload the image.
110+
111+
<div class="video-container"><iframe src="https://www.loom.
112+
com/embed/0655708e67db4b5c8798820b7d12dc5f?sid=fff3c351-e8e7-4879-9c78-0510057a7b6a" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
113+
114+
### Centering map on marker tap
115+
116+
To center a map on a marker tap, move to the **Properties Panel > Google Map > enable the Centering
117+
Map on Marker Tap toggle**.
118+
119+
<div class="video-container"><iframe src="https://www.loom.
120+
com/embed/3f069a4c31fa45b99e52ebc56a992876?sid=6cafde11-c24f-4a79-915b-2dc158b5f680" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
121+
122+
## On Marker Tap [Action Trigger]
123+
124+
Sometimes, you might want to receive a callback when a user taps on a marker. This can be useful for
125+
dynamically displaying additional information about the location, opening a detailed view, or
126+
initiating other actions based on the selected marker.
127+
128+
Here’s how you do it:
129+
130+
- Select the **Google Map** widget.
131+
- From the Properties panel, select **Actions** and open the **Action Flow Editor**.
132+
- Under the action trigger **On Marker Tap**, add any actions here.
133+
134+
![marker-tap.png](..%2Fimgs%2Fmarker-tap.png)
135+
136+
## Advanced Customizations
137+
138+
You can customize the appearance and behavior of this widget using the various properties available
139+
in the properties panel.
140+
141+
### Allow Interacting With the Map
142+
143+
By default, the map interaction feature is enabled, allowing users to drag, zoom in, and zoom out on
144+
the map. However, you can disable the **Allow Zooming the Map** and **Show Zoom Buttons** on the Map
145+
options
146+
if you wish to restrict the zoom functionality.
147+
148+
To access these settings, navigate to the **Properties Panel > Google Map > Allows Interacting with
149+
the Map**.
150+
151+
<div class="video-container"><iframe src="https://www.loom.
152+
com/embed/1b06bfc1365f4fc68f15089d4f84d798?sid=ff33ea94-cd7f-4b4e-822e-6fe0743dbd27" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
153+
154+
### Show User Location
155+
156+
When enabled, a blue dot appears on the map to indicate the user's current location. If the map is
157+
moved, users can re-center their location by clicking the button at the top right side.
158+
159+
To enable this option, navigate to the **Properties Panel > Google Map > enable the Show User
160+
Location toggle**.
161+
162+
:::note
163+
When you enable this option, make sure to set the **Initial Location to Global Properties > Current
164+
Device Location**.
165+
:::
166+
167+
<div class="video-container"><iframe src="https://www.loom.
168+
com/embed/97a4aca1b5e84313b106f9c98aa15957?sid=5340a30a-fb0f-43bf-92e1-bf305b0630b7" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
169+
170+
### Showing Compass
171+
172+
While exploring the map, users may rotate the map (which can make it difficult to trace the route).
173+
Enabling compass will allow users to bring the map to its original direction.
174+
175+
To enable the compass, navigate to the **Properties Panel > Google Map > enable the Show Compass
176+
toggle**.
177+
178+
<div class="video-container"><iframe src="https://www.loom.
179+
com/embed/53822c6ac9fa4455b43748c46f127ebb?sid=ac9ac978-03f5-49e3-b627-43c6dee5c6b0" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
180+
181+
### Enabling map toolbar
182+
183+
The Toolbar, located at the bottom right of the map, becomes visible when a user selects a marker.
184+
It offers quick access to either a map view or directions in the Google Maps mobile app.
185+
186+
To enable the toolbar, navigate to the **Properties Panel > Google Map > enable the Show Map Toolbar
187+
toggle**.
188+
189+
<div class="video-container"><iframe src="https://www.loom.
190+
com/embed/890f12d9134f4c8793cc6dce17ce0929?sid=cefa00a8-680a-4871-a18a-5586a33c65a5" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
191+
192+
### Showing Traffic on Map
193+
194+
Showing traffic on the map allows user to know the flow of traffic on the roads and helps them
195+
decide on a better route.
196+
197+
To show live traffic on a map, navigate to the Properties Panel > Google Map > enable the Show
198+
Traffic on Map toggle.
199+
200+
<div class="video-container"><iframe src="https://www.loom.
201+
com/embed/8cf915f27803412cb9b2247b5cfb257a?sid=45dac67a-0f2d-4f7d-a390-25b2ce8bc16f" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
202+
203+
204+
205+
85.7 KB
Loading

0 commit comments

Comments
 (0)