Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@
if (!google || !google.maps.places) {
return;
}

// Read configuration from element info
var types = (addressElementInfo.customData?.autocompleteTypes || 'address').split(',').map(t => t.trim());
var options = {
types: ['establishment']
types: types
};

// Add country restriction if configured
if (addressElementInfo.customData?.countryRestriction) {
options.componentRestrictions = { country: addressElementInfo.customData.countryRestriction };
}

var gPlace = new google.maps.places.Autocomplete(addressEl[0], options);
google.maps.event.addListener(gPlace, 'place_changed', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ public virtual string ApiKey
[Display(GroupName = SystemTabNames.Content, Order = -6800)]
public virtual string CountryLabel { get; set; }

[Display(GroupName = SystemTabNames.Content, Order = -6250)]
[UIHint(UIHint.Textarea)]
public virtual string AutocompleteTypes { get; set; } = "address";
// Options: "address", "establishment", or "address,establishment"

[Display(GroupName = SystemTabNames.Content, Order = -6260)]
public virtual string CountryRestriction { get; set; }
// ISO country code (e.g., "au" for Australia, "us" for USA)

/// <summary>
/// Always use AddressValidator to validate this element
/// <remarks>hide from EditView</remarks>
Expand Down Expand Up @@ -188,6 +197,11 @@ public override ElementInfo GetElementInfo()
{
var baseInfo = base.GetElementInfo();
baseInfo.CustomBinding = true;
baseInfo.CustomData = new Dictionary<string, object>
{
{ "autocompleteTypes", AutocompleteTypes ?? "address" },
{ "countryRestriction", CountryRestriction }
};
return baseInfo;
}

Expand Down