// initially display germany var lat = 50.75653081787912, lon = 9.262980794432847, zoom = 5; 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; zoom = 11; 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) { $.ajax({ type: 'GET', url: '/filling_stations/favourites/toggle/'+station.id, dataType: 'json', timeout: 1000, success: function(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) { var info = $('#station_info'); info.empty(); info.addClass('filling_station_info'); var cell1 = $('