Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Turns MapsLib into a Class #42

Closed
wants to merge 3 commits into from
Closed

Turns MapsLib into a Class #42

wants to merge 3 commits into from

Conversation

ffflabs
Copy link
Contributor

@ffflabs ffflabs commented Feb 4, 2015

In its current state, MapsLib is an object in the global scope. To invoke its own function type properties, it addresses the global object. When you want to change the API key or the table id, you must either edit the mapslib library or overwrite the default properties of the global object.

I wanted to encapsulate all the logic in a class, so that you could interact with the MapsLib instance without ever editing the file or operating on the global element. With this you can even create N instances of MapsLib for N maps, if the need came. To instance a new mapslib object, you do

var MapsLibInstance = new MapsLib({
              /*fusionTableId:      "1m4Ez9xyTGfY2CU6O-UgEcPzlS0rnzLU93e4Faa0",

              //*New Fusion Tables Requirement* API key. found at https://code.google.com/apis/console/
              //*Important* this key is for demonstration purposes. please register your own.
              googleApiKey:       "AIzaSyA3FQFrNr5W2OEVmuENqhb2MBB2JabdaOY",

              //name of the location column in your Fusion Table.
              //NOTE: if your location column name has spaces in it, surround it with single quotes
              //example: locationColumn:     "'my location'",
              locationColumn:     "geometry",

              // latitude and longitude your map will be centered on
              lat : 41.8781136,
              lng : -87.666778,

              locationScope:      "chicago",      //geographical area appended to all address searches
              recordName:         "result",       //for showing number of results
              recordNamePlural:   "results",

              searchRadius:       805,            //in meters ~ 1/2 mile
              defaultZoom:        11,             //zoom level when map is loaded (bigger is more zoomed in)
              addrMarkerImage:    'images/blue-pushpin.png', // set to empty '' to hide searched address marker
              currentPinpoint:    null,
            */
            });

that roughly equals calling the former initialize() method.

I changed the current examples accordingly, and also included an optional AMD module definition and a index_amd.html file showing the use case with require.js.

@derekeder
Copy link
Owner

Thanks for this @amenadiel! Pulling it into a working branch: https://github.com/derekeder/FusionTable-Map-Template/tree/maps-lib-class

@derekeder derekeder mentioned this pull request Feb 11, 2015
@derekeder
Copy link
Owner

Working on this in a new pull request #45

@derekeder derekeder closed this Feb 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants