I'm working on a project which involves the usage of maps where it is make operations, like plotting marker
or polylines
.
The functionalities are working fine but I 'm facing difficulty on using multiple map service provider.
I want to perform same set operation using a open layer. For do that, I have to change in all the places, like controllers and views. Plus, I have a service which feed the data to the controller in required format.
But I'm not sure how to create an abstraction layer for different map service provider on the client side.
I have all the map related logic in the controller
Basically I'm looking for some guidelines and suggestion which will help to switch between multiplier service provider with minimum number of changes.
Follows my controller code:
taxiFleetControlPanel.controller("overviewController", function ($scope,$location,sensorService,appService,nodeService,settingService,$timeout,$rootScope,instanceService,assetApiService) {
//google maps
function initMap() {.....}
function addMarker(){.....}
function addpolyLines(){....}
//openlayer maps
function openlayerInitMap() {.....}
function openlayerAddMarker(){.....}
function openlayerAddpolyLines(){....}
if there is requriment to use openalyer map the i will comment initMap(); in the same controller
funtion init(){
initMap();
//openlayerInitMap()
}
init();
})
Is there a better way to do it?
there are so many other dependent functions as well I have not put to maintain simplicity.
I tried the follow idea:
Wrote two different controllers and changed the controller in the route but if the any change made in one controller i will literally copy paste the same set of methods to other i am not able to maintain a clean code
Note: The application can support multiple service provider like Google maps, openalyers and leaflet.