I’ve some js files organized this way (see source):
-
gmaps4rails.base.js: contains all the logic-
gmaps4rails.googlemaps.js: contains functions -
gmaps4rails.bing.js: contains functions with the same name as the previous file
-
So basically, base calls createMarkers() which is in both googlemaps and bing.
From now, I load only one among gmaps4rails.googlemaps.js and gmaps4rails.googlemaps.js, depending on the map API I need, so it works fine.
Now I’d like to be able to have all files loaded (and keep them separate) BUT of course only include the code of the desired maps API.
Basically I think about something like:
if desiredApi == "googlemaps"
include GoogleMapsNameSpace content in BaseNameSpace
Thanks in advance.
If I understand correctly you just want to be able to use either the google maps API or the bing API or someother based on the user selection (or some other criteria)? For that, instead of trying to merge the correct API into your base object, why don’t you just refer a ‘mapService’ from your base object and select the mapService based on the criteria you want?
Something like this:
Is this what you want to do?
Hope this helps