Skip to content

Commit e39a903

Browse files
authored
Merge pull request #32 from FlutterFlow/pooja/maps
Integration - Google Maps
2 parents 460ec52 + 83853a1 commit e39a903

19 files changed

+563
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"label": "Google Cloud"
3+
}
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/generate-maps-keys)
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"label": "Maps"
3+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Generate Maps Keys
3+
sidebar_position: 1
4+
5+
---
6+
7+
# Maps & Places APIs
8+
9+
FlutterFlow natively supports **Google Maps**, providing a seamless and efficient way to embed
10+
interactive maps into your FlutterFlow apps. It also supports **Places API** that returns formatted location data and imagery about establishments, geographic locations, or prominent points of interest.
11+
12+
## Add Maps APIs
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+
1. 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+
2. You may receive a prompt from Google Cloud to add a billing account. Please add a billing account
26+
to continue.
27+
28+
3. 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+
<p></p>
35+
36+
:::warning
37+
To secure your API keys, refer to the [**Best Practices guide: Secure API Keys**](..%2F..%2Fcloud%2Frestrict-keys.md)
38+
:::
39+
40+
- Click on the Credentials menu from the left panel.
41+
42+
- Find the key for the platform you need, and copy the key.
43+
44+
### Add keys to FlutterFlow
45+
46+
Now add the API keys platform wise to FlutterFlow Settings page
47+
48+
![g-maps-settings.png](..%2Fimgs%2Fg-maps-settings.png)
49+
50+
### Create a new Key if not available
51+
52+
If you don't find the Android key (auto created by Firebase) or iOS key (auto created by
53+
Firebase) in the Google developer console, here are the steps to create one:
54+
55+
- On your Cloud console, click the **Credentials** menu on the left.
56+
57+
- Click on the **+ Create Credentials** at the top.
58+
59+
- Click on the **API Key** to create a new key for the Android app. Similarly, create one for
60+
iOS and Web.
61+
62+
<div class="video-container"><iframe src="https://www.loom.
63+
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>
64+
65+
66+
## Add Places APIs
67+
68+
To enable **Places API** in your project, please follow the steps under
69+
["Add Maps API" section](#add-maps-apis) and additionally also enable Places API from the API
70+
library if not
71+
already enabled.
72+
73+
![places-api.png](imgs/places-api.png)
74+
75+
85.7 KB
Loading
364 KB
Loading
390 KB
Loading
440 KB
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Move Map Center Action
3+
---
4+
5+
6+
# Move Map Center [Action]
7+
8+
This action allows you to center the map on a specified location, such as setting the pickup and drop-off points. You can define the location either by directly inputting the latitude and longitude values or by using a variable.
9+
10+
:::info[Prerequisites]
11+
- To implement this feature, add a Google Maps widget to your page or component.
12+
[**Learn how.**](google-maps-widget.md)
13+
- If you wish to enable users to select locations from a dropdown using FlutterFlow's PlacePicker
14+
widget, you can also integrate the Place Picker widget into your map view. [**Learn more here**](place-picker-widget.md).
15+
:::
16+
17+
18+
Assuming you've set up the Place Picker widget on your Google Maps widget view, let's add a button that triggers the action to move the map center, so the map centers on the newly selected location.
19+
20+
In our example, we've added an IconButton with a location pin icon. For the button's OnTap
21+
action trigger, we'll add the Move Map Center action and set the LatLng to the LatLng of the
22+
Place Picker's selected place. You must check if the PlacePicker value (or the variable holding your new LatLng) is set before calling the Move Map Center action.
23+
24+
![move-map.png](imgs/move-map.png)
25+
26+
27+
28+
29+
30+
31+

0 commit comments

Comments
 (0)