This add-on provides:
-
A custom data type for representing a Google Place.
-
A related field that allows users to select a Google Place.
-
Two predefined fragments:
-
A fragment for displaying the rating and user reviews of a Google Place.
-
A fragment for presenting detailed information about a Google Place.
-
The following table shows which version of the add-on is compatible with which version of the platform:
| Jmix Version | Add-on Version | Implementation |
|---|---|---|
2.4.4 |
1.0.0 |
gr.netmechanics.jmix:jmix-google-place-starter:1.0.0 |
2.5.x |
1.1.0 |
gr.netmechanics.jmix:jmix-google-place-starter:1.1.0 |
2.6.x |
1.2.0 |
gr.netmechanics.jmix:jmix-google-place-starter:1.2.0 |
2.7.x |
1.3.0 |
gr.netmechanics.jmix:jmix-google-place-starter:1.3.0 |
2.8.x |
1.4.0 |
gr.netmechanics.jmix:jmix-google-place-starter:1.4.0 |
For manual installation, add the following dependencies to your build.gradle:
implementation 'gr.netmechanics.jmix:jmix-google-place-starter:<addon-version>'There are two settings to specify.
| Setting | Type | Default Value | Description |
|---|---|---|---|
jmix.gplace.apiKey |
Required |
Google API key. |
|
jmix.gplace.languageCode |
Optional |
en |
The language in which to return results and for map UI elements and tile labels. |
By default, you can define those settings in application.properties file.
Alternatively, implement a Spring bean of type gr.netmechanics.jmix.gplace.GPlacePropertiesProvider to provide these settings (e.g. to use Jmix Application Settings add-on).
|
Note
|
The add-on uses Google’s Places API (New) and the Maps Embed API (optional). The Google API key must support the |
Add-on provides a new datatype GooglePlaceRef.
You can define an entity attribute with the GooglePlaceRef datatype using Studio.
As a result, Studio generates the following attribute definition:
@Column(name = "PLACE")
private GooglePlaceRef place;|
Note
|
The actual value stored in the database is a JSON string. {"id":"ChIJ__tbmhQR0q7gENr8mSs","displayName":"Heraklion International Airport N. Kazantzakis","address":"Heraklion 716 01, Greece","latitude":35.3395461,"longitude":25.1760645} |
In a detail view you can add the field from studio Component Palette window
or through code
<view xmlns="http://jmix.io/schema/flowui/view"
xmlns:nm="http://schemas.netmechanics.gr/jmix/ui"
focusComponent="form">
...
<layout>
<formLayout id="form">
<nm:googlePlacePicker id="placeField" property="place"/>
</formLayout>
...
</layout>
</view>A fragment for displaying the rating and user reviews of a Google Place.
<fragment class="gr.netmechanics.jmix.gplace.component.GooglePlaceRatingFragment">
<properties>
<property name="placeId" value="ChIJbVXA_SNamhQRGtyjFLUFH9E"/>
</properties>
</fragment>| Property | Type | Default Value | Description |
|---|---|---|---|
placeId |
Required |
The place ID for which to display rating and user reviews. |
|
apiKey |
Optional |
<config> |
Google API key. If not specified, the key from the configuration will be used. |
languageCode |
Optional |
<config> |
Specifies the language for UI elements and map tile labels. If not specified, the key from the configuration will be used. |
useGoogleIcon |
Optional |
true |
Specifies whether to use the Google icon. If not, the place icon provided by the Google Places Service will be used. |
hideReviews |
Optional |
false |
Specifies whether the reviews will be hidden. |
A fragment for presenting detailed information about a Google Place.
<fragment class="gr.netmechanics.jmix.gplace.component.GooglePlaceInfoFragment">
<properties>
<property name="placeId" value="ChIJbVXA_SNamhQRGtyjFLUFH9E"/>
</properties>
</fragment>| Property | Type | Default Value | Description |
|---|---|---|---|
placeId |
Required |
The place ID for which to display detailed information. |
|
apiKey |
Optional |
<config> |
Google API key. If not specified, the key from the configuration will be used. |
languageCode |
Optional |
<config> |
Specifies the language for map UI elements and tile labels. If not specified, the key from the configuration will be used. |
useGoogleIcon |
Optional |
true |
Specifies whether to use the Google icon. If not, the place icon provided by the Google Places Service will be used. |
hideMap |
Optional |
false |
Specifies whether the map will be hidden. |
hideOpeningHours |
Optional |
false |
Specifies whether the opening hours information will be hidden. |
zoom |
Optional |
14 |
Initial zoom level of the map. |
mapType |
Optional |
roadmap |
Specifies the type of map tiles to load. |
The add-on caches requests to Google’s APIs. It includes a built-in cleaning Quartz job, which is disabled by default. You can use it for periodic cache cleaning, as described below.
To use the configuration of the Quartz job for cache cleaning, do the following:
-
Include Quartz add-on in your project as described in the Quartz / Installation.
-
Set the jmix.gplace.use-default-cleaning-cache-quartz-configuration property to true:
jmix.gplace.use-default-cleaning-cache-quartz-configuration=true -
Change the CRON expression if necessary using the jmix.gplace.cleaning-cache-cron property.
jmix.gplace.cleaning-cache-cron=0 0 1 1 1/1 ? *




