Ticket #322 (closed feature: wontfix)

Opened 9 years ago

Last modified 8 years ago

dynamic loading of JS libraries associated with Layers

Reported by: jrf Owned by:
Priority: minor Milestone: 2.5 Release
Component: Layer Version:
Keywords: Cc:


Since several popular map libraries are non-trivial in size, it would be good to load them only when the user selects that backdrop map. Such dynamic loading is challenging, because it is difficult to know when the layer has finished loading. We tried the following:

  1. Putting an "onLoad" attribute in the SCRIPT element
    • fails because _
  2. Checking for the existence of named entities that won't exist until the script loads
    • this might work...
  3. other ideas?

Once dynamic loading is solved, the layer switcher should be extended to indicate when a library is loading: display a little spinner image next to the layer until it finishes loading.

Change History

Changed 9 years ago by sderle

  • milestone changed from 2.2 Release to 2.3 Release

Changed 8 years ago by euzuro

  • component changed from general to Layer

Changed 8 years ago by crschmidt

  • milestone changed from 2.3 Release to 2.4 Release

Changed 8 years ago by euzuro

  • milestone changed from 2.4 Release to 2.5 Release

Changed 8 years ago by crschmidt

So, the best way to do this, if you need this functionality:

  • Create a map. add your non-commercial layers to the map. Make your map variable global.
  • Seperate the functionality of adding the commercial layers into a seperate function.
  • Add a script element to your page with an onload that calls that function:
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR2WgIWO4X4SoXnfmo_1F9_zl7r7hT7s7xvI_08hh6tzoOcqOGZ0zKkjA" 
                            type="text/javascript" onload="setTimeout(add_gmaps,1000)"></script>

This technique is used successfully on MetaCarta Maps.

Changed 8 years ago by sderle

  • status changed from new to closed
  • resolution set to wontfix

looks like this might be a FAQ but not something directly fixable.

Note: See TracTickets for help on using tickets.