|
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
0 commit comments