Geolocation points collection Edit mode

Vote:
 

My question is about the way to work with a collection of geolocation points in Editor mode.

I'm working with CoordinatesBlock, and Ted Gustaff googlemaps editor to add geolocation for some shops in a country. With a single CoordinatesBlock for each shop it works really well.

Here is my code:

[ContentType(DisplayName = "CountryShops", GUID = "b02b50d2-e86e-46c2-824c-0932685d9848", Description = "Country Shops")]

public class CountryShops: PageData    
{
       
[Display(Name = "Shop 1",           GroupName = SystemTabNames.Content,           Order = 10)]        
[ClientEditor(ClientEditingClass = "tedgustaf.googlemaps.Editor")]        
public virtual CoordinatesBlock shop1 { getset; }    

[Display(Name = "Shop 2",           GroupName = SystemTabNames.Content,           Order = 10)]        
[ClientEditor(ClientEditingClass = "tedgustaf.googlemaps.Editor")]        
public virtual CoordinatesBlock shop2 { get; set; }    
}
public class CoordinatesBlock : SiteBlockData
   {
       [CultureSpecific(true)]
       [Display(Name = "Longitute",
          GroupName = SystemTabNames.Content,
          Order = 10)]
       public virtual string Longitude { getset; }
       [CultureSpecific(true)]
       [Display(Name = "Latitude",
          GroupName = SystemTabNames.Content,
          Order = 20)]
       public virtual string Latitude { getset; }
   }

But now I would like to add more geolocation points (more shops) "with LinkItemCollection way", for n shops in the country, without the need to change my code adding one more
CoordinatesBlock each time I need an extra geolocation point for another shop, what would be the way to have this functionality working???

Regards
#131429
Jul 24, 2015 14:13
Vote:
 

Hi,

I think that the easiest way is to use ContentArea property where you will store CoordinatesBlock blocks.

You could annotate this ContentArea with AllowedTypes attribute and then only Location block could be stored in your property.

[AllowedTypes(typeof (CoordinatesBlock))]
public virtual ContentArea Locations { get; set; }
 
#131430
Jul 24, 2015 14:19
Vote:
 

Thaks Grzegorz, but in that case, how can I use Ted Gustaf googlemaps editor???

[ClientEditor(ClientEditingClass = "tedgustaf.googlemaps.Editor")] 

This solution works as long as the editor must introduce 2 floats for latitude and longitude, without de beauty of Ted Gustaf googlemaps editor, isn't it???.

Regards.
#131431
Jul 24, 2015 15:16
Vote:
 

So maybe you could create another block type - ShopCoordinateBlock.

[AllowedTypes(typeof (ShopCoordinatesBlock))]
public virtual ContentArea Locations { get; set; }



public class ShopCoordinatesBlock: : SiteBlockData
{
[Display(Name = "Shop 1",           GroupName = SystemTabNames.Content,           Order = 10)]        
[ClientEditor(ClientEditingClass = "tedgustaf.googlemaps.Editor")]        
public virtual CoordinatesBlock shop1 { get; set; }    
}

Then on the ContentArea you click "Create new block". Only ShopCoordinatesBlock types are allowed. The new block editor appear. In the editor you should have access to Geolocation property editor.

#131457
Jul 27, 2015 15:47
Vote:
 

Thank you Grzegorz, it's as easy as you clearly explain.

Regards

#131523
Jul 29, 2015 13:16
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.