RequireJS Installation | Documentation

RequireJS is a modular JavaScript file loader that some sites use to organize and optimize their JavaScript files. If your website (or platform) is using it, rest assured that SimpleMaps will still work. Although SimpleMaps is not AMD aware, you can easily install SimpleMaps as a legacy third-party library.

Here's what you need to do (example):

  1. Choose the map you want to install:

  2. Add your map files: mapdata.js and usmap.js to the RequireJS library folder as defined by baseUrl in the configuration file. In this example, this is the lib directory. Also, add the require.js to this directory.
  3. In the RequireJS app.js file, use shim within the config method to include the mapdata.js and usmap.js files. Here is what our example configuration looks like:
  4. requirejs.config({
          baseUrl: 'lib',
          paths: {
              app: '../app'
          },
          shim: {
            'mapdata': {
              exports: 'simplemaps_usmap_mapdata'
            },
            'usmap': {
              exports: 'simplemaps_usmap'
            }
          }
      });
  5. At the end of the app.js file, load another JavaScript file, app/main.js, which will contain the application logic.
  6. requirejs(['app/main']);
  7. In the main.js file, require both mapdata and usmap:

    define(function (require) {
          require('mapdata');    
          require('usmap');
      });
  8. On your webpage, add the following code within the <head>:
  9.  <script data-main="app" src="lib/require.js"></script>
  10. On your webpage, add this snippet where you want the map to appear:
  11. <div id="map"></div>
  12. That's it the map should be working! If you are having trouble, download an example with our USA map.
Download US Example

Home | License | Privacy | Releases | Testimonials | Resources | Documentation | Order Lookup | All Maps | FAQs
Formerly FlashUSAmap.com and FlashWorldMap.com
SimpleMaps.com is a product of Pareto Software, LLC. © 2010-2024.