Copied to clipboard

Flag this post as spam?

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


  • Darren Wilson 238 posts 646 karma points
    Apr 25, 2017 @ 16:15
    Darren Wilson
    0

    Different Marker Icons

    Hi Jonathan,

    What a great package - great instructions too! Thanks!

    Quick question - is it possible to merge multiple nested maps so I can have different marker icons?

    Cheers Darren

  • Jonathan Richards 288 posts 1742 karma points MVP
    Apr 26, 2017 @ 08:26
    Jonathan Richards
    0

    Hi Darren,

    If we are talking about the front-end, when you place a Terratype inside a Razor template, then Opps, this is an oversight, while in the @Html.Terratype() command you can override the position, provider, zoom and some other values, I've forgotten Icon. I will rectify this in the next release (I don't have a released date, but I suspect it would be in the next few weeks)

    The only way I can think of, which I'm not suggesting is great, is that you could define lots of Terratype Maps with different Icons, wrap them all up inside an Archetype or Nested Content that allows multiple field/doctypes. So that the Content Editor could select which map they wanted to use, this would then feed all the way to when the maps get rendered.

    Cheers for this

    Jonathan

  • Darren Wilson 238 posts 646 karma points
    Apr 26, 2017 @ 08:42
    Darren Wilson
    1

    Hi Jonathan,

    Thanks for getting back to me! This is what I did in the end - works perfectly. I've got a couple of other questions…

    1. Is is possible to add a KML layer to the map OR use an already created map with the KML in place? Apologies, I've only used Google maps for very basic stuff before.

    2. Having a bit of a problem getting the labels to appear - followed the manual and used the razor included but they're not appearing (Labels are switched on within the datatype too:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.MapPage> @using Terratype; @using ContentModels = Umbraco.Web.PublishedContentModels; @{ Layout = null; } @Html.Terratype(new Options { Provider = new Terratype.Providers.GoogleMapsV3() { Variety = new Terratype.Providers.GoogleMapsV3.VarietyDefinition() { Satellite = false } }, Height = 600, MapSetId = 1, Zoom = 11, Position = new Terratype.CoordinateSystems.Wgs84("59.05609, -2.99102") }) @foreach (var record in Model.Content.NestedMaps) { var name = record.GetPropertyValue<string>("heading"); var map = record.GetPropertyValue<Terratype.Models.Model>("googleMapLocation"); @Html.Terratype(new Options { MapSetId = 1 }, map, @<text> @name is at @map.Position </text> ) }

    I must be doing something wrong.

    Thanks for your help.

    Darren

  • Jonathan Richards 288 posts 1742 karma points MVP
    Apr 26, 2017 @ 09:28
    Jonathan Richards
    0

    Hey Darren,

    There isn't any built-in KML ability in Terratype. You can call Html.Terratype() with an option that overwrites the position value, if you called this method for each KML item, I could see this doing the same functionality.

    @* 
        Given that kmlList is a list of kml values - I haven't shown how that list is created 
        Given that Model.Content.Map is a Terratype map that exists in the model, it's position is irrelevant as it's overwritten by the kml value
    *@
    
    @foreach (var kmlEntry in kmlList)
    {
        @Html.Terratype(new Options
        {
            Position = new Terratype.CoordinateSystems.Wgs84(kmlEntry),
            MapSetId = 1,
        }, Model.Content.Map)
    }
    

    As for the Label not working, you're code looks good, so I'm wondering if a bug has crept in. If its alright, I'll try and give you an update on this later - I need to check this over properly which means I require some free time to take a look and I can only apologise.

    If you do wish to take a look at this yourself, can I point you to Terratype.GoogleMapsV3.Renderer.js which is the javascript file that runs on the front-end and the lines between 265 and 289 that are responsible for displaying the label. I would check if they are failing in some way.

    Cheers

    Jonathan

  • Darren Wilson 238 posts 646 karma points
    Apr 26, 2017 @ 09:36
    Darren Wilson
    1

    Brilliant, I'm not sure what to do with it tho ha ha. Do I add this to the existing razor? Where would I store the KML files? Sorry for my ignorance ;-)

    Also, would it easier to use an existing google map - I have one with all the layers in place and plot the TerraType data onto this - don't know how to do this either ha ha.

    Thanks again for your help. This is defo a 'must-have' plugin!

  • Jonathan Richards 288 posts 1742 karma points MVP
    Apr 26, 2017 @ 10:11
    Jonathan Richards
    1
    • Do I add this to the existing razor?

      Yeah, that code snippet is for your Razor template, but as for where you store your KML file and how you load that into the kmlList variable, I do think the options are endless and really depends on your circumstances, but it will involve you writing some code. I'm wondering if this sort of question would be better asked in a generalized forum question, so that you can get a wider selection of views.

    • Also, would it easier to use an existing google map - I have one with all the layers in place and plot the TerraType data onto this - don't know how to do this either ha ha.

      Yep, that is what the snippet does, it re-uses a Map that exists already in your doc type, but changes the location of the icon for each KML entry. So if the KML file contained 1000 places, then the output would be a single map with 1000 icons on it. The styling, zoom and other options would all come from the map and whatever is defined in it. You will be pleased to know that Terratype automatically uses the Clustering module in Google Maps, so it can handle oodles of icons.

      I do really understand, that if Terratype did handle KML files automatically, this would really help you out, but sadly its not something I plan to write as its not something I need in my day-to-day work. As ever, I'm always happy to accept a pull-request from anyone who wrote that functionality, but I can imagine it would involve many hours/days of works.

  • Darren Wilson 238 posts 646 karma points
    Apr 26, 2017 @ 10:37
    Darren Wilson
    0

    Yeah, that's a great thing - the clustering!

    My KML stuff is on a custom Google Map not within my site. I think I'm going to try and load the KML data into the variable as a JSON object using your snippet and see where I get with that.

    Thanks again for your help - let me know if you find a bug with the labels.

    Darren

  • Jonathan Richards 288 posts 1742 karma points MVP
    Apr 30, 2017 @ 18:20
    Jonathan Richards
    0

    Terratype 1.0.12 has now been released and allows custom icons when being rendered.

  • Darren Wilson 238 posts 646 karma points
    May 02, 2017 @ 08:56
    Darren Wilson
    0

    Hi Jonathan,

    Thanks for this! How do I upgrade?

    Darren

  • Jonathan Richards 288 posts 1742 karma points MVP
    May 02, 2017 @ 09:06
    Jonathan Richards
    0

    Hi Darren,

    If you originally used NuGet to install Terratype, then you should find on the NuGet screen an update button, click it.

    If you installed via the Umbraco Package manager, then just repeat the process. The package has been made, so that the code files can be copied over.

    If you installed the package, by some hardcore ninja method (Unzipping, copying or something even more hideous), feel free to question your life.

    But, all in all, there is nothing special in the installation method, it just places some dll's in your /bin/ folder and some static files in your /App_Plugins/ folder. Repeating this, with the new files is all that is required.

    Cheers

    Jonathan

  • Darren Wilson 238 posts 646 karma points
    May 02, 2017 @ 09:27
    Darren Wilson
    1

    Cheers - I'm no hardcore ninja - I went through the Umbraco package manager!

    Darren

  • Darren Wilson 238 posts 646 karma points
    Jun 06, 2017 @ 16:10
    Darren Wilson
    0

    Hi Jonathan,

    Finally got round to fixing this map! I've had to give up on the KML layer stuff - it's a bit beyond me.

    I still can't get the pop-ups working though. I've updated to the latest version but I'm getting the following error when inspecting in chrome:

    js:48 Uncaught TypeError: Cannot read property 'maxZoom' of undefined at Ag.

    Here's the code I'm using to display the map. Not getting any front error, just nothing when you click.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.MapPage>
    
    @using Terratype;
    
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    
    @{
        Layout = "SiteMaster.cshtml";
    }
    
    
    @Html.Terratype(new Options     
    
    {         
        Provider = new Terratype.Providers.GoogleMapsV3()         
        {             
            Variety = new Terratype.Providers.GoogleMapsV3.VarietyDefinition()             
            {                 
                Satellite = false             
            }         
        },         
    
        Height = 600,         
        MapSetId = 1,         
        Zoom = 11,         
        Position = new Terratype.CoordinateSystems.Wgs84("59.05609, -2.99102")     }) 
    
    @foreach (var record in Model.Content.NestedMaps)
    {
        var name = record.GetPropertyValue<string>("heading");
        var map = record.GetPropertyValue<Terratype.Models.Model>("googleMapLocation");
    
        @Html.Terratype(new Options { MapSetId = 1 }, map,             
            @<text>                 
                @name is at @map.Position             
            </text>         
        )     
    }
    
  • Darren Wilson 238 posts 646 karma points
    Jun 06, 2017 @ 16:11
    Darren Wilson
    1

    Sorry, forgot to add thanks to the end!

    Darren

  • Jonathan Richards 288 posts 1742 karma points MVP
    Jun 12, 2017 @ 16:35
    Jonathan Richards
    0

    Hi Darren,

    Been a bit busy at CodeGarden last week, so have taken a bit longer to answer this.

    On the face of it, I can't see anything wrong with the razor you have posted. I've repeated bits of it locally and it works for me - obviously I don't have your content, so have had to construct something similar.

    As for the error message, that's the bit that I find intriguing. The call stack doesn't match my code; Just focusing on the bit inside my code:-

    • File Terratype.GoogleMapsV3.Renderer.js: Line 310
    • File Terratype.GoogleMapsV3.Renderer.js: Line 427
    • File Terratype.GoogleMapsV3.Renderer.js: Line 46

    While the file is mine, those line numbers don't match up with any code of my last release of 1.0.13, which make me think your not using my latest version or you have some process happening which is mangling my code (eg. minifying the script files).

    On a seperate note, if I had to guess what google maps js library is complaining about is you have an invalid location stored in one of your nested content entries. I suggest taking a look at your content. Maybe you have a blank entry or you have amended your nested content property type without amending the content. Though I would be very interested in what it is, as I would love to add more error handling to stop others having the same issue.

    Cheers

    Jonathan

    ps. That coordinate is in the Orkneys :)

  • Darren Wilson 238 posts 646 karma points
    Jun 14, 2017 @ 16:26
    Darren Wilson
    1

    Hi Jonathon,

    Thanks - I'll check I'm running the right version!

    I was hoping to got to CG17 - I was at CG16. Had great time!

    Our client it on Orkney!

    Darren

  • Darren Wilson 238 posts 646 karma points
    Jun 21, 2017 @ 14:49
    Darren Wilson
    1

    Hi Jonathan,

    Yeah, I'm using the latest version - very odd. I'll keep experimenting with it.

    Cheers Darrenenter image description here

  • Geoff Beaumont 75 posts 104 karma points
    Nov 30, 2017 @ 12:14
    Geoff Beaumont
    0

    I'm seeing this error too.

    The line (in markerclusterer.min.js) that triggers it is: o.map_.mapTypes[o.map_.getMapTypeId()].maxZoom)

    I seem to get it regardless of which markers are displayed, and always when the first call to refresh (line 346 of Terratype.GoogleMapsV3.Renderer.js) is made. The actual line in that function that leads to the error is 348: m.gmap.setZoom(m.zoom); Subsequent calls don't trigger the error.

    The markers are displayed correctly, and clustered.

    Line numbers above from Terratype 1.0.14.

  • Jonathan Richards 288 posts 1742 karma points MVP
    Nov 30, 2017 @ 12:26
    Jonathan Richards
    0

    Thank you for this report. I presume a difference has crept in between the current version of Gmaps (v3.30) and the version of Marker Cluster that I bundle in with Terratype (Which is around 6 months old).

    You can manually update the Marker Cluster file yourself, you will find it located at /App_Plugins/Terratype.GoogleMapsV3/Scripts/markerclusterer.min.js

    Regardless, I will try this out myself this weekend or so.

  • Geoff Beaumont 75 posts 104 karma points
    Nov 30, 2017 @ 13:07
    Geoff Beaumont
    1

    Hi Jonathan,

    I've dropped the latest version of Marker Clusterer into my dev environment, and it's fixed the error. I can't see any nasty side effects.

Please Sign in or register to post replies

Write your reply to:

Draft