Address doesn't have a constructor that takes 0 arguments
Closed this issue · 0 comments
bjarnef commented
Previous we could do something like the following the populate data to Our.Umbraco.GMaps.Models.Map
object and serialize the JSON to store in a property.
However in v2 it seems the Our.Umbraco.GMaps.Models.Address
doesn't have a constructor that takes 0 arguments.
if (googleAddress != null)
{
var map = new Our.Umbraco.GMaps.Models.Map
{
Address = new Our.Umbraco.GMaps.Models.Address
{
Coordinates = $"{googleAddress.Coordinates.Latitude.ToString(CultureInfo.InvariantCulture)}, {googleAddress.Coordinates.Longitude.ToString(CultureInfo.InvariantCulture)}",
FullAddress = googleAddress.FormattedAddress,
PostalCode = store.Zip,
City = store.City,
State = "",
Country = store.CountryName
}
};
var mapJson = Newtonsoft.Json.JsonConvert.SerializeObject(map);
// Store JSON in GMaps property editor
node.SetValue(ContentModels.Store.GetModelPropertyType(_publishedSnapshotAccessor, x => x.Location).Alias, mapJson);
}
_contentService.SaveAndPublish(node);
The Address
and Coordinates
properties are set here:
Our.Umbraco.GMaps/Our.Umbraco.GMaps.Core/Models/Map.cs
Lines 18 to 20 in ca7663a
It would probably make sense to add overload of these, e.g. to pass in coordinates to constructor new Location(lat, lng)
or to use literal notation.