Copied to clipboard

Flag this post as spam?

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


  • Simon Miller 13 posts 36 karma points
    May 31, 2018 @ 07:04
    Simon Miller
    1

    Terratype serving incorrect position and zoom when used in Grid Editor

    Hi all,

    Found this issue with both 1.0.16 and 1.0.18 when using a Google v3 map in Terratype when the datatype is a property on a Grid (via LeBlender).

    No matter what the value is set to by the content editor for the instance of the Grid , Terratype serves the default values set at the datatype level. The following is in my Grid's view file:

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    var item = Model.Items.ElementAt(0); 
    
    var map = item.GetValue<Terratype.Models.Model>("map");
    
    @Html.Terratype(map)
    

    When inspecting the values of map.Position and map.Zoom, the datatype defaults are returned.

    However, if I make a second variable to the raw value like so:

    var mapJson = System.Web.Helpers.Json.Decode(item.GetRawValue("map"));
    
    @Html.Terratype(new Options { Position = new Terratype.CoordinateSystems.Wgs84(mapJson.position.datum), Zoom = mapJson.zoom }, map)
    

    By manually passing the dynamic Json from the raw property value to the Options override, I get the correct map.

    Cheers,

    Simon

  • Jonathan Richards 288 posts 1742 karma points MVP
    May 31, 2018 @ 11:03
    Jonathan Richards
    0

    Hi Simon,

    I'm not someone who uses or understands the Grid, so sorry for my ignorance.

    For my Terratype tests, I use

     @CurrentPage.GetGridHtml("grid")
    

    To render a grid, and let whatever or however the grid does it stuff to pop out a rendered Terratype map if its present within the Grid's content.

    My quick tests on 1.0.18, suggest this is still functioning.

    I wanted to try and replicate what you are doing, so can you tell me how you are calling your 'Grid View file' and where is it located. The one with the following contents:-

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    var item = Model.Items.ElementAt(0); 
    
    var map = item.GetValue<Terratype.Models.Model>("map");
    
    @Html.Terratype(map)
    

    oh, and describe this using steps to someone who doesn't understand the Grid.

    Cheers

    Jonathan

  • Simon Miller 13 posts 36 karma points
    Jun 01, 2018 @ 00:28
    Simon Miller
    0

    Hi Jonathan,

    The views used by the grid editor are in ~\Views\Partials\Grid\Editors.

    Editors are loaded on a main view like so (where contentBlocks is the doctype property containing the grid editors datatype):

    @Html.GetGridHtml(Model.Content, "contentBlocks")
    

    This Umbraco article is the best place to learn up on Grids:

    https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Grid-Layout

    When I use the automatically generated "Map" grid editor (presumably this was made by Terratype when I installed it) it renders the correct position and zoom on the website as overridden by the content editor:

    "Map" works correctly. My "Location" does not

    Here is my custom "Location" grid setup via LeBlender. The "Map (Australia)" datatype is an instance of Terratype with the v3 Google Maps engine. The default position is set in the datatype to central Sydney. The issue is, when rendering the Terratype HTML helper in the Location.cshtml grid view, no matter what the content editor overrides as the map position and zoom for "Location" it will always show the default Sydney position. That is, until I found my workaround as described in the first post.

    Here is my Grid editor setup via LeBlender

Please Sign in or register to post replies

Write your reply to:

Draft