How to roll out your own map SDK
Before I proceed with this blog; let me warn you that I am no expert on building mapping solutions. I worked with a start up who was planning to roll out their own mapping solution but they later dropped the plan. This entire post reflects the knowledge I have gain during this 1 and half year of R&D, Reading, learning and development experience.
Introduction
Adding maps to mobile app is piece of cake if you are using google maps API. However after the recent pricing model change by google it may not be such an easy options for many apps based business. Google has caught us off guard this time!
Well lets say you are part of business whose app is heavily dependent on google maps. One of those delivery apps, Cab services, or Real Estate renting & buying services etc.. And the recent pricing model came as a shock to your organization and they decided to find alternate solution or build their own to save the recurring cost from google maps API.
So what are the alternative to Google Maps to use in mobile app?
Honestly there is none! If you are comparing the google maps speed, offline mode, accuracy, route options, places/address database and user experience there is no competition to google maps. However there are other players which can be explored Here (here, here is name of the company), Bing Maps(Does not have a official mobile SDK yet, but there are ways..), MapBox etc..
Every option comes with its own initial cost & recurring cost.
Rolling out your own mapping solution with help of open source libraries, is obviously the most difficult route. But not all businesses requires every feature that google maps has to offer. If the requirement is containable and business has a patience & dedication to survive through the development cycles then DIY approach may work.
Maps are nothing but data, everything on the map such as buildings, streets, point of interest, water bodies, rail tracks etc.. are stored somewhere and presented in the form of Raster & Vector maps. Raster is nothing but image and these images are stored on the server in form of tiles (one unit). Maps are rendered as a tiled image and each tile represent specific area on the map. As we navigate Zoom +/- or Left/Right the tile units changes and it renders the right image based on the raster unit and that is how the maps are rendered on web and in mobile.
Now Raster will only give you images and it does not tell you about the roads and paths or buildings or rails track etc.. That information comes from vector tiles. For example if we want a show the navigation from point A to Point B on a actual road of the map then we will have to draw a path from A -> B on the map images and to do that we will need the path coordinates which are aligned with the map data or in same coordinate space.
Where to get Raster & Vector ?
- OSM : OSM is great source for Map data. Simply click on the below link and you can download raster images for entire planet earth.
2. Commercial Databases
There are some legit sources who sale maps data (Format can vary as well as the information).
There was a company called mapzen. They were collecting vector data from OSM and hosting it as a part of their vector tile service. OSM data is in OSM (XML) format and its non-linear, It is hard to extract data or process it! Mapzen was providing this data in form of Geojson/topojson which is much easier to understand and process. Unfortunately mapzen shut down early this year but their tools are open source. If you are really getting your hands dirty with map data mapzen tools are the best place to get started.
Once the raster & vector data is collected and hosted we are ready to build our mapping solution. Again since we are not building the map solutions of google scale so our raster & vector data size will be limited to a city or a region at most so server & scaling requirements would not be very high end.
Map solution would consist of following
- Tile Rendering
- Vector Data Rendering
Tile Rendering
Once the coordinate system, tile naming conventions and zoom levels etc.. are figured out rendering tiles is not difficult. Tile rendering code can be adopted from popular opensource libraries.There are some really good open source libraries which does tile rendering such as Leaflet, D3 & Tangram. In Android or IOS Webview is simplest way to implement the rendering or custom native view could also be implemented depending on the requirement.
Vector Data Rendering
To draw vector data on top of raster, we need a graphic library. Not the heavy CPU intensive game engine sort of graphics library but a simple 2D graphics utility would also do. This graphics library will be used to draw lines, polygons etc.. to represent roads or buildings on the maps. Drawing buildings on the map would be very advance task and requires 3D graphics library but drawing lines & roads can be accomplished with webview and web toolkits. One of the advance map rendering open source library is vizicities, F4Maps etc..
Few Advance graph rendering examples.
Once the tile rendering and vector data rendering is coupled toghether your DIY map solution is ready to be used :)
Drawing roads and understanding roads information such as connectivity and traffic status is most important for navigation or logistics related apps. Roads data is generally available in the form of nodes & edges and using that information a path needs to be identified between source and destination. Now from here a new territory of “Path Finding” & Graph Traversal starts which will try to cover in next post.
Happy mapping till then!