Opened 9 years ago

Closed 8 years ago

#322 closed feature (wontfix)

dynamic loading of JS libraries associated with Layers

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

Description

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 (6)

comment:1 Changed 9 years ago by sderle

  • Milestone changed from 2.2 Release to 2.3 Release

comment:2 Changed 9 years ago by euzuro

  • Component changed from general to Layer

comment:3 Changed 9 years ago by crschmidt

  • Milestone changed from 2.3 Release to 2.4 Release

comment:4 Changed 9 years ago by euzuro

  • Milestone changed from 2.4 Release to 2.5 Release

comment:5 Changed 9 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.

comment:6 Changed 8 years ago by sderle

  • Resolution set to wontfix
  • Status changed from new to closed

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

Note: See TracTickets for help on using tickets.