So this is not the cleanest thing possible and maybe some views filter should be made but I created it mostly for the purpose of adding extra button to search a search api index data with user current location. What maybe somebody doesn't know is that you can get user location with html5, so you will only need some little code and I also used reversed geocoding to get address from google api because I already have a filter that uses geocoded data.
Probably this would be better off in some non exposed filter or I don't know where exactly, for now this is how I solved it and activate it with calling of getLocation function on click.
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert("Geolocation is not supported by this browser.");
}
}
function showPosition(position) {
var gglGeocoder = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + position.coords.latitude + "," +position.coords.longitude;
//var gglGeocoder = "https://maps.googleapis.com/maps/api/geocode/json?latlng=34.0204989,-118.4117325";
$.getJSON( gglGeocoder, function( json ) {
//console.log((json.results[0].formatted_address));
$(".views-widget-filter-field_ol_locator_geofield_latlon input[type=text]").focus();
$(".views-widget-filter-field_ol_locator_geofield_latlon label").css('display', 'none');
$(".views-widget-filter-field_ol_locator_geofield_latlon input[type=text], textarea").val(json.results[0].formatted_address);
});
p.s.
for google reverse geocoding this is helpful https://developers.google.com/maps/documentation/geocoding/#ReverseGeoc…