Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place tag detection and replacing "-" with "" #2734

Merged
merged 19 commits into from
Jun 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions app/assets/javascripts/tagging.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
function addTag(tagname, selector) {

selector = selector || '#tagform';
if (tagname.slice(0,5).toLowerCase() === "place") {
place = tagname.split(":")[1];
place.replace("-", " ");
geo = geocodeStringAndPan(place);
}
else {
var el = $(selector);

var el = $(selector);

el.find('.tag-input').val(tagname);
el.find('.tag-input').val(tagname);

el.submit();
el.submit();
}

}

Expand Down Expand Up @@ -80,3 +86,27 @@ function initTagForm(deletion_path, selector) {
return el;

}

function geocodeStringAndPan(string, onComplete) {
var url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + string.split(" ").join("+");
var Blurred = $.ajax({
async: false,
url: url,
complete: function(data) {
geometry = data.responseJSON.results[0].geometry.location;
lat = geometry.lat;
lng = geometry.lng;

var geo = [lat, lng];

if (geo.length > 0) {
var r = confirm("This looks like a location. Is this full description of the location accurate?");
console.log(geo[0]);
console.log(geo[1]);
if(r) {
addTag("lat:" + geo[0].toString() + ",lng:" + geo[1].toString()+",place:"+string);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so I think we can put off refactoring addTag for now -- or do it in an independent PR. This should just submit the HTML form. I'm going to merge it!

}
}
},
});
}