Not really a question, and i'm sure it can be improved, but I wanted to strongly type the output from this awesome editor. Wrote a tiny Value Converter for it. I can share here. Not sure if worth including in your lib. Great work!
[PropertyValueType(typeof(Location))]
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
public class AngularGoogleMapsConverter : IPropertyValueConverter
{
public bool IsConverter(PublishedPropertyType propertyType)
{
return propertyType.PropertyEditorAlias == "AngularGoogleMaps";
}
public object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
{
return ConvertSource(source);
}
public object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview)
{
return source;
}
public object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview)
{
return null;
}
private static Location ConvertSource(object source)
{
if (source == null)
{
return null;
}
var sourceString = source.ToString();
var splitSource = sourceString.Split(',');
if (!splitSource.Any())
{
return new Location();
}
try
{
var lat = Convert.ToDecimal(splitSource[0]);
var lng = Convert.ToDecimal(splitSource[1]);
var zoom = Convert.ToInt32(splitSource[2]);
var location = new Location { Lat = lat, Long = lng, Zoom = zoom };
return location;
}
catch (Exception ex)
{
return new Location();
}
}
}
public struct Location
{
public decimal Lat { get; set; }
public decimal Long { get; set; }
public int Zoom { get; set; }
}
<script>
var map;
function initialize() {
var mapOptions = {
zoom: @Model.Location.Zoom,
center: new google.maps.LatLng(@Model.Location.Lat, @Model.Location.Long)
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Property Value Converter
Not really a question, and i'm sure it can be improved, but I wanted to strongly type the output from this awesome editor. Wrote a tiny Value Converter for it. I can share here. Not sure if worth including in your lib. Great work!
Coolio, saved me a bundle of time, #h5yr
Have implemented this code. It is now availbale in version 1.0.6
is working on a reply...