// initially go to Brandenburger Tor var lat = 52.516275, lon = 13.377704, zoom = 13; var map; var filling_stations = {}; var filling_station_markers; query_location = function(updater) { if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { lat = position.coords.latitude; lon = position.coords.longitude; if(updater){ updater(lat, lon); } }); } } update_map = function() { var lonLat = new OpenLayers.LonLat( lon, lat ) .transform( new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984 map.getProjectionObject() // to Spherical Mercator Projection ); map.setCenter (lonLat, zoom); } load_filling_stations = function() { var url = '/filling_stations?latitude=' + lat + '&longitude='+ lon + '&type=all&radius=5&sort=dist'; $.ajax({ type: 'GET', url: url, success: function(data) { data.stations.forEach(function(station) { if (!(station.id in filling_stations)) { filling_stations[station.id] = station; filling_stations[station.id].marker = false; } }); update_filling_station_markers(); } }); } clicked_on_filling_station_marker = function(station, marker) { return function(data) { console.log(station); console.log(marker); $.ajax({ type: 'GET', url: '/filling_stations/favourites/toggle/'+station.id, dataType: 'json', timeout: 1000, success: function(data) { console.log(data); if (data.state == 'favourite') { marker.setUrl('/static/img/filling_station_favourite_marker.png'); } else { marker.setUrl('/static/img/filling_station_marker.png'); } }, contentType : 'application/json' }); } } display_station_information = function(station) { return function(event) { console.log(station); var info = $('#station_info'); info.empty(); info.addClass('filling_station_info'); var cell1 = $('