Saturday, September 9, 2017

We were reviewing Bing Maps API.
Bing Maps helps you visualize spatial data. Users love to know where a store is or how to get there. And the data does not always need to come from Bing. It can be overlaid over the map. As long as the data has geographical coordinates, it can be used with the maps. Previously this data was sent over as xml, now there is support for more succint format as GeoJson 
Recently Bing Maps announced support for drag and drop of GeoJson format data over maps. When an application is written to use Bing Maps, it can load the maps and the geojson module. It will listen for drag and drop events. with file reader APIs, each geojson file dropped on the map is  read and overlaid.
The steps involved for the application include :
Using HTML5 to load the local files
Select the files from a form input
Each file contains a collection of features where each feature is a location.
The location list is then overlaid on the map.
Load the GeoJson module:
Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () {
            //Setup the drag & drop listeners on the map.
            var dropZone = document.getElementById('myMap');
            dropZone.addEventListener('dragover', handleDragOver, false);
            dropZone.addEventListener('drop', handleFileSelect, false);

        });
var shapes = Microsoft.Maps.GeoJson.read(geoJsonText);
myMap.entities.push(shapes);
#codingexercise
Prune a binary tree with root to leaf paths whose sum is less than k
we use a recursive post order traversal and eliminate the leaves whose sum is greater than k. Nodes higher up become leaves.
Traverse the left of the root and get left
Traverse the right of the root and get right
if the root is a leaf, and the max of left and right together with the current sum is lesser than k, delete the root and return null

return root.

No comments:

Post a Comment