Copied to clipboard

Flag this post as spam?

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


  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Mar 29, 2017 @ 08:46
    Jeavon Leopold
    1

    Transition from AngularGoogleMaps?

    Is there anyway to transition from AngularGoogleMaps package to Terratype?

  • Jonathan Richards 288 posts 1742 karma points MVP
    Mar 29, 2017 @ 10:08
    Jonathan Richards
    100

    Hi Jeavon,

    There isn't anything that I've written that does this automatic. I sort of thought about that there are 4 different formats that AGM supports (2 different csv, 1 json and 1 xml formats) and that god only knows where people can place maps; inside Vorto, Archetype, Nested Content, Grids that I could be opening a huge bag of worms if I tried to write something that could do the job properly. Another issue, is that I wanted to make Terratype.Model (The strongly typed class that represents a map's data) to be a lot more complicated than the old AngularGoogleMaps.Model.

    Terratype was my attempt at a clean break from AGM, eg. It needed to only store Json and it needed to understand different Coordinate Systems (WGS-84, GCJ-02 etc)

    I suppose if you had AGM properties defined within a bog standard DocType, you could do

    1. Add a new Terratype datatype to the existing DocType that contains the AGM.
    2. Write some code using the ContentService, to read each content node based off your DocType, read the AGM value (Lets presume its a string of format Latitude, Longitude, Zoom). Chop up the string yourself into Lat, Lng & Zoom variables. Replace the Lat, Lng and Zoom in the following Json and save this Json to your Terratype property.

      { "zoom": 13, "position": { "id": "WGS84", "datum": "55.843314,-4.429961" }, "lookup": "" }

    3. Delete your AGM property from your DocType

    4. Rename the alias of your Terratype property to be the same as the AGM property.

    5. Then you would need to change whatever code you are using in your Razor templates to stop using AngularGoogleMaps.Model and instead use Terratype.Model. Though Lat, Lng are defined differently in Terratype (It has this concept of Coordinate types; WGS-84, GCJ-02. So you need to call a method to return the Coordinate System you wish to use). So a rewrite of your front end code here would be required. Note: Terratype can render maps in razor by itself now, so you might want to use that code instead.

    All in all, yes anyone can write something that solves their particular situation, but writing something that would work for everyone, would be a nightmare.

    Cheers

    Jonathan

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Mar 29, 2017 @ 12:39
    Jeavon Leopold
    1

    Hi Jonathan,

    Thanks for your suggestion, it is a little tricky given AGM is deprecated so we will need to move over to Terratype to keep up to date with fixes.

    Many thanks for your hard work on Terratype!

    Jeavon

  • David Zweben 268 posts 754 karma points
    Feb 07, 2018 @ 21:27
    David Zweben
    0

    Hi Jonathan,

    I am looking to do basically what you've described here, use Terratype to simply output Lat and Lng to a template.

    Can you give an example of what ContentService code is needed to output this?

    Thanks.

  • Jonathan Richards 288 posts 1742 karma points MVP
    Feb 09, 2018 @ 09:50
    Jonathan Richards
    1

    Hi David,

    I presume you didn't mean the ContentService, as who would use that in a template (It makes direct calls to the database, it not for rendering, you use ContentCache for that).

    Then its a matter of figuring out what coordinates system you want, lets say you want WGS84, then its a simple

     @Model.Content.Map.Position.ToWgs84().Latitude
     @Model.Content.Map.Position.ToWgs84().Longitude
    

    Cheers

    Jonathan

  • David Zweben 268 posts 754 karma points
    Feb 10, 2018 @ 14:16
    David Zweben
    1

    This was what I needed, thanks.

Please Sign in or register to post replies

Write your reply to:

Draft