Code Monkey home page Code Monkey logo

organicity-urban-data-observatory's People

Watchers

Pral2a avatar Dimitrios Amaxilatis avatar James Cloos avatar  avatar  avatar Deligiannidou Katerina avatar  avatar Johnny Choque avatar

organicity-urban-data-observatory's Issues

Replace Mapzen with Google Maps

Mapzen is being deprecated so we'll need to move to the Google Maps API:

function querySearch(query) {
return $q.all([getMetadata(query), getPlacesMapzen(query)])
.then(function(data) {
if(data.length === 0) {
//enable scrolling on body if there is no dropdown
angular.element(document.body).css('overflow', 'auto');
return data;
}
//disable scrolling on body if dropdown is present
angular.element(document.body).css('overflow', 'hidden');
return joinSearches(data);
});
}
function getMetadata(keywords){
keywords = keywords.replace(' ', '+');
return asset.getMetadata(keywords);
}
function getPlacesMapzen(location){
location = location.replace(' ', '+');
return $http.get('https://search.mapzen.com/v1/autocomplete?api_key=search-h8Qe8fY&text='+ location);
}
function filterPlaces(places){
if (!places || !places.data || places.data.features.length === 0){ return [];}
places = places.data.features.slice(0, 3); //just first 5 results
return _.map(places, getMapzenPlaceReadyForModel);
}
function filterEntities(assets){
if (!assets || assets.length === 0){ return [];}
return _.map(assets, getMetadataReadyForModel);
}
function getMapzenPlaceReadyForModel(place){
var searchResult = {
type: 'location',
name: place.properties.label,
longitude: place.geometry.coordinates[0],
latitude: place.geometry.coordinates[1]
};
return new SearchResultLocation(searchResult);
}
function getMetadataReadyForModel(asset){
return new SearchResult(asset);
}
function joinSearches(data){
var e = filterEntities(data[0]);
var p = filterPlaces(data[1]);
return p.concat(e);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.