5 Replies Latest reply on Oct 5, 2015 7:52 PM by andrew_watson

    Worldwide Map Customizations

    s-k

      I'm customizing the Worldwide map to include features it doesn't currently have, specifically adding leaflet plugins. I know some of these features I want to add are already under development but they won't be released for some time.

      I would like to preform all my customizations using a custom HTML resource I place in the page with the world map. I can make all the changes via JavaScript in the HTML resource and then I won't need to modify anything on the server.

      The map variable is giving me issues. I cannot reference the map variable within my JavaScript due to scope.

       

      How can I access the map variable so I can add my plugins?

      Any attempts of mine to use the namespace functions haven't been successful.

       

      Here is the map setup code:

      $(function(){ // Wait for DOM load

        var vol = SW.Core.namespace('SW.Core.Volatile.WorldMaps');
        var opts = { lat: 40, lng: -90, zoom: 4, resourceid: '----myMapResourceID----', optimize: true, tileset: '' };
        var map = vol[opts.resourceid] = SW.Core.WorldMap.Viewer.Create('worldmap'+opts.resourceid, opts );
        map.Refresh();
        SW.Core.View.AddOnRefresh(function(){ SW.Core.Volatile.WorldMaps[opts.resourceid].Refresh(); });
      });


      If anyone could point me in the right direction that would be very helpful.



      Thanks!

        • Re: Worldwide Map Customizations
          Peter.Cooper

          We do not support extending our software via javascript, only via the SDK. That said, folks do many interesting things (javascript and/or css) with the knowledge that a future version might break it. Developer to developer: The mapping component intentionally tries to abstract away the internals, which includes leaflet. It is unlikely, but we may need to swap that out some day. That's why it's a convoluted to dig out a reference to leaflet.

           

          var leaflet_mapobj = SW.Core.Volatile.WorldMaps[myMapResourceID].leaflet(); // this is the leaflet map object.

           

          Considering that you're putting in a custom html resource on the same view as the map, you can just hard code that to match the ID in question.


          If you do something cool with this information, please procure and upload a screenshot.

          • Re: Worldwide Map Customizations
            andrew_watson

            Hi S-k

             

            You've done some great work on this, thanks for sharing. Out of interest have any of you guys noticed lately that the performance on the open weather maps has been quiet bad. I've emailed the support team there and they advise that the issue's are congestion problems on there end and there isn't much we can do about it, however they advised that if you buy a subscription you get access to a different server and there are no performance issues. I asked them how we integrate the subscription in and they advised this

             

             

            just add &appid=yourAppidHere to your request URLs temples, for example use

             

            http://{s}.tile.openweathermap.org/map/snow/{z}/{x}/{y}.png&appid=yourAppidHere’

             

            instead of

             

            http://{s}.tile.openweathermap.org/map/snow/{z}/{x}/{y}.png’