Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Ivan Ponomarenko 20 posts 104 karma points
    Feb 12, 2018 @ 14:20
    Ivan Ponomarenko

    Cant create instance of Terratype.Models.Model

    Hi comunity,

    I am trying to render google map without placed it into Content.

    In other words, I get the data of this map from another source in Json as string, like:


    So, for render map i use below code:

    @foreach (System s in systems.Docs)
        @Html.Terratype(new Model(s.Location))

    And gets the error enter image description here

    Terratype version 1.0.14

    Umbraco version 7.7.3

  • Jonathan Richards 250 posts 1522 karma points MVP
    Feb 14, 2018 @ 09:30
    Jonathan Richards

    Hi Ivan,

    I can see what you are trying to achieve, but to render, Terratype needs loads more info like what type of map to render, api keys, styling etc, this is done when you create a new datatype. Without this @Html.Terratype() has no idea whether you want a blue and green Bing Map showing latest traffic or a dusty coloured Google Map just showing Terrain and no roads.

    So right now, sadly you do need to create content, you only need one though, as you can set the position of the map yourself in your razor template. Can I suggest a setting node, or a site node.

    Being able to render maps without content isn't something I'm planning to write, as it would be a lot of work for me, for very little value.

    Technical reason: Right now the config code is in javascript and sets a json block that the renderer reads, again all in javascript code. So the creating and rendering of maps is actually all done in js code, (Also as you already know, GMaps, Bing maps etc, are actually just js libraries, so really its all done using js code) not in c# code. Currently there is a subset of values you can set, called Options, to override those json values, which is managed in c# classes that map to json values. To be able to create your own map from scratch, I would need to create c# classes for all aspects of the configuration of a map, this would include styling which if you every take a look at will boggle the mind to its complexity. This would be a major undertaking. Sorry.



Please Sign in or register to post replies

Write your reply to: