I'm new to Umbraco, using version 7.10.4. I created data types and doc types as per Terratype manual. But when it comes to rendering the map on the fronted i'm getting these errors:
.cannot convert from 'Terratype.Options' to 'Terratype.Models.Model'
.cannot convert from 'Terratype.Models.Model' to 'System.Func
namespace Terratype.Models{
public class Model {
public Provider Provider { get; internal set; }
//public Position Position { get; set; }
public Icon Icon { get; internal set; }
public int Zoom { get; set; }
public string Lookup { get; set; }
public int Height { get; set; }
}
public class Icon
{
}
public class Provider
{
}}
I don't understand why you are creating your own Terratype Model. The whole point is to the use the one that comes with Terratype. I mean stating the obvious, your one won't render because you haven't written any code for it to do so, you have literally created an empty class with no functionality, but with a similar name to the real one in Terratype package, and then asked why doesn't it work.
If you want to use the model that is provided in Terratype, you have to create a datatype, place that datatype within your own document type and then create content based on your document type. Only then can you take that content property value and use it to render on the front-end with the command @Html.Terratype(). All of these steps are described in the manual.
I was so confused with that model in the manual, now the issue is i'm using modelsbuilder api so when i generate the models, it throws an error name space Terratype not found, that is the main reason i thought i should put that model in my code might do the magic.
///<summary>
/// Location
///</summary>
[ImplementPropertyType("coordinates")]
public Terratype.Models.Model Coordinates
{
get { return this.GetPropertyValue<Terratype.Models.Model>("coordinates"); }
}
This is my generated model, but it is throwing an error when referencing Terratype. What am i missing
If I had to make a guess, as your question isn't related to Terratype per se, but ModelsBuilder, is that you have more than one assembly and have so far have only referenced Terratype into the one that contains the Umbraco UI but not the assembly that you have ModelsBuilder running in. You need to install Terratype everywhere that you make references to it.
If its not that above situation, then I will need to know lots more info like what Umbraco version, what ModelsBuilder (and how is it setup; API mode etc), how is your solution organised, Nuget or Package Manager, to be able to help further.
You are my life saver, I wasn't install the package in my Models Project. Now those errors goes away. But now the issue is when i try to get the location it is showing null value, but in backoffice the data is there. My View code is below
Seeing in your code that you are casting location.Coordinates to (Terratype.Models.Model) is a large warning sign that location.Coordinates isn't actually of type Terratype.Models.Model. Its a little hard for me to figure out what it is from here, but I would focus your attention on that.
Help on Nested Content Terratype
Hello,
I'm new to Umbraco, using version 7.10.4. I created data types and doc types as per Terratype manual. But when it comes to rendering the map on the fronted i'm getting these errors: .cannot convert from 'Terratype.Options' to 'Terratype.Models.Model' .cannot convert from 'Terratype.Models.Model' to 'System.Func
My Terratype Model
I don't know where exactly i'm missing the point.
Hi Advance Ngwarati
I don't understand why you are creating your own Terratype Model. The whole point is to the use the one that comes with Terratype. I mean stating the obvious, your one won't render because you haven't written any code for it to do so, you have literally created an empty class with no functionality, but with a similar name to the real one in Terratype package, and then asked why doesn't it work.
If you want to use the model that is provided in Terratype, you have to create a datatype, place that datatype within your own document type and then create content based on your document type. Only then can you take that content property value and use it to render on the front-end with the command
@Html.Terratype()
. All of these steps are described in the manual.Cheers
Jonathan Richards
Thank you Jonathan,
I was so confused with that model in the manual, now the issue is i'm using modelsbuilder api so when i generate the models, it throws an error name space Terratype not found, that is the main reason i thought i should put that model in my code might do the magic.
This is my generated model, but it is throwing an error when referencing Terratype. What am i missing
Hi Advance Ngwarati
If I had to make a guess, as your question isn't related to Terratype per se, but ModelsBuilder, is that you have more than one assembly and have so far have only referenced Terratype into the one that contains the Umbraco UI but not the assembly that you have ModelsBuilder running in. You need to install Terratype everywhere that you make references to it.
If its not that above situation, then I will need to know lots more info like what Umbraco version, what ModelsBuilder (and how is it setup; API mode etc), how is your solution organised, Nuget or Package Manager, to be able to help further.
Cheers
Jonathan Richards
You are my life saver, I wasn't install the package in my Models Project. Now those errors goes away. But now the issue is when i try to get the location it is showing null value, but in backoffice the data is there. My View code is below
}
Back Office(Umbraco 7.10.4)
What is weird is, the name the location i can access render it, but location is showing me null.
Advance Ngwarati
Seeing in your code that you are casting
location.Coordinates
to(Terratype.Models.Model)
is a large warning sign thatlocation.Coordinates
isn't actually of typeTerratype.Models.Model
. Its a little hard for me to figure out what it is from here, but I would focus your attention on that.Cheers
Jonathan Richards
Thanks Jonathan,
It worked like a charm, I should put error handling before rendering the map. Thanks again for the help.
is working on a reply...