Copied to clipboard

Flag this post as spam?

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


  • Christina 127 posts 390 karma points notactivated
    Dec 17, 2018 @ 13:35
    Christina
    1

    How can I display edited label

    Hi I want to display an editable label in a nested map?
    @map.Label.Content doesn't work , how can I display it Many Thanks / Christina

        @Html.Terratype(new Options {
        Provider = new Terratype.Providers.GoogleMapsV3() {
            Variety = new Terratype.Providers.GoogleMapsV3.VarietyDefinition() {
                Basic = true
    
            }
        },
    
        Height = 400, MapSetId = 2, Zoom = 5,
        AutoShowLabel=true,
        Position = new Terratype.CoordinateSystems.Wgs84("61.122441,14.599928")
    }
    
    )
    
    @foreach (var record in Model.Nested)
    {
        var name = record.GetPropertyValue<string>("mapName"); var map = record.GetPropertyValue<Terratype.Models.Model>("map");
        @Html.Terratype(new Options { MapSetId = 2 }, map, @<text> @name is at @map.Label </text> )
    }
    
  • Jonathan Richards 288 posts 1742 karma points MVP
    Dec 17, 2018 @ 16:00
    Jonathan Richards
    0

    Hi Christina,

    Maybe the manual/instructions are not clear enough, and to be honest, I had to remind myself what I had done.

    The way Labels are setup is that either you have a custom one using the code

       @Html.Terratype(new Options { MapSetId = 2 }, map, @<text> @name is at some contents from editor </text> )
    

    (Just like you did)

    OR

    You allow Terratype to render a styled label with the contents set by the editor. Using the code

       @Html.Terratype(new Options { MapSetId = 2 }, map)
    

    Now, I fully understand, as its not obvious that you wanted a label with both editor and custom contents. Currently this is unsupported behavour, though I do have it in my roadmap which involves creating your own Label class inherited from Terratype.Labels.Standard class.

    I can though give you a 'hack' that allows you to access the label contents that are set by the Content Editor as well as providing your own custom Html.

     @Html.Terratype(new Options { MapSetId = 2 }, map, @<text> @name is at @(map.Label != null ? ((Terratype.Labels.Standard) map.Label).Content : null) </text> )
    

    I hope this helps.

    Cheers

    Jonathan

  • Christina 127 posts 390 karma points notactivated
    Dec 20, 2018 @ 08:54
    Christina
    0

    Hi Jonathan many thanks for helping me.

    I have another question, is it possible to have a custom style to the map ?

    Thanks again Christina

  • louisjrdev 107 posts 344 karma points c-trib
    Dec 20, 2018 @ 09:11
    louisjrdev
    0

    For map styling you may want to look at something like this: https://snazzymaps.com/

  • Jonathan Richards 288 posts 1742 karma points MVP
    Dec 20, 2018 @ 09:58
    Jonathan Richards
    0

    Hi Cristina,

    You can pick between numerous styles when you are first configuring the map in the developer section - at the time your are creating your own datatype.

    https://our.umbraco.com/packages/backoffice-extensions/terratype/#package-gallery-4

    Cheers

    Jonathan

    ps. Snazzymaps.com will only help you if you wish to render your own map and not use the Terratype renderer, eg. @Html.Terratype() Razor command.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies