FORUMS
Remove All Ads from XDA

[GUIDE][Difficulty: Advanced] Send an SMS with Address, Speed, and URL for a Map Pin

851 posts
Thanks Meter: 1,884
 
Post Reply Email Thread
9th March 2016, 01:01 PM |#11  
Member
Thanks Meter: 4
 
More
This is the link it is giving me: https://www.google.com/maps/place/-3...70.6200612,14z

No marker and the address is not accurate.

Edit: Address was not accurate because of where I was (office) went outside and it worked perfectly, still there is no pointer in the map.
 
 
10th March 2016, 04:01 PM |#12  
patrickpetersen's Avatar
Senior Member
Flag Esbjerg
Thanks Meter: 25
 
More
Quote:
Originally Posted by MishaalRahman

Your phone is lost, or you've got a relative who you're okay with sharing your location to. If you're driving, it's hard to give them an exact location, but thanks to the power of Tasker and a Javascriptlet, you can do that and more. With this task, you'll be able to automatically send an SMS with the current Address, current Speed that the phone is traveling, and a URL that drops a pin on the phone's location in Google Maps. Very helpful for easily finding a location! I would like to thank Redditor /u/popillol for figuring out the proper Javascriptlet to parse the Google Maps Geocoding API results.

Prerequisites

  1. Secure Settings plugin if you are rooted and want to be able to automatically toggle location mode
  1. Create a new Profile and select the Event context. Go to Phone and select Received Text. For the Type, leave it at Any and the Sender field blank. However for the Content field, choose a trigger phrase that you will share with your trusted relatives. This trigger phrase should be unique enough that there is no way it will trigger based off of any random text message.
  2. Create a Task and name it 'Get Location.'


Now, for the task itself. Be warned that this involves some Javascript, so be sure you copy/paste the functions in properly otherwise it might not work.
  1. Variables --> Variable Set. Set Name to %from and To to %SMSRF. This gets the phone number that the text was sent from and puts it into a variable called %from.
  2. (If Rooted) Plugin --> Secure Settings. Choose Location Mode/High Accuracy under System+ Actions.
  3. Location --> Get Location. Set the source as Any.
  4. Net --> HTTP Get. Under Server:Port, put in the following URL to access the Google Maps Geocoding API:
    Code:
    maps.google.com/maps/api/geocode/json?latlng=%LOC&sensor=false
    Set Mime Type as text/xml
  5. Code --> Javascriptlet. For the code, add the following:
    Code:
    var locj = JSON.parse(global("%HTTPD"));
    var spd = Number(global("%LOCSPD"))*2.23693629;
    var lat = global("%LOC").split(",");
    var lon = Math.abs(lat[1]);
    lat = lat[0];
    var latd = Math.floor(lat);
    var latm = ( lat - latd )*60;
    var lats = ( latm - Math.floor(latm) )*60;
    latm = Math.floor(latm);
    var lond = Math.floor(lon);
    var lonm = ( lon - lond )*60;
    var lons = ( lonm - Math.floor(lonm) )*60;
    lonm = Math.floor(lonm);
    lat = latd+"\°"+latm+"\'"+lats.toFixed(1)+"%22N";
    lon = lond+"\°"+lonm+"\'"+lons.toFixed(1)+"%22W";
    var url = "https://www.google.com/maps/place/"+lat+"+"+lon+"/@"+global("%LOC")+",14z";
    
    if ( locj.results.length > 0 )
    {
    var short = locj.results[0].address_components[0].short_name;
    if ( short.search(/[^\d-]/) == -1 )
    short = "";
    else
    short = "("+short+") ";
    var add = locj.results[0].formatted_address;
    add = short+add.replace(", USA","");
     }
  6. Phone --> Send SMS. For the Number, put in %from. For the Message, put in the following:
    Code:
    %add 
    Speed ~ %spd mph 
    URL: %url


That's it! As mentioned in the Reddit thread for this, you can use AutoInput to automate turning on/off location services if you aren't rooted, but it's a bit of a messy implementation so I recommend just leaving location services on.

Quote:
Originally Posted by mnhs1010

Can someone edit the script and provide me for global? I am in Pakistan and its not showing accurate drop pin.

Try to follow the instructions from the redditor or manually switch the 22N to 22S and 22W to 22E
The Following User Says Thank You to patrickpetersen For This Useful Post: [ View ] Gift patrickpetersen Ad-Free
13th March 2016, 05:24 PM |#13  
Senior Member
Flag Karachi
Thanks Meter: 73
 
More
Quote:
Originally Posted by patrickpetersen

Try to follow the instructions from the redditor or manually switch the 22N to 22S and 22W to 22E

its working fine 3 days but now it is sending the last same location always not new location.
18th March 2016, 08:27 PM |#14  
Member
Flag Cleveland, TN
Thanks Meter: 1
 
More
Quote:
Originally Posted by Cryorus

Thanks for the tip, it seems that step 3. Get Location takes a while (around a minute or more) to complete, after that, Flashing %LOC doesn't return anything.

Edit: Working now, I turned options for GPS to use Wifi and Bluethooth and it worked, but the link isn't sent completly, the hyperlink breaks at the first comma. Example: www.url.com/22w22s1234,etc.

Edit 2: Just read that there is nothing to do about it... gona find a way around.

Edit 3: Found a way around using the bitly API, the problem now is even if I change the location N to S (I'm in South America) it doesn't pin anything. (It doesnt even with N)

I'm having this problem as well, the "Get Location" times out no matter how high I set the time out value to be. I've Turned on WiFi and Bluetooth scannaing to no avail. Whenever the task runs, I see the GPS icon show up in my status bar. And Google Maps has no problem getting my location quickly and accurately. I'm not sure what's going on
18th March 2016, 08:31 PM |#15  
Member
Thanks Meter: 4
 
More
Quote:
Originally Posted by Ben Abel

I'm having this problem as well, the "Get Location" times out no matter how high I set the time out value to be. I've Turned on WiFi and Bluetooth scannaing to no avail. Whenever the task runs, I see the GPS icon show up in my status bar. And Google Maps has no problem getting my location quickly and accurately. I'm not sure what's going on

Did you test it outside? It takes a while to get my location here at my work, but outside it is super fast.
18th March 2016, 08:39 PM |#16  
Member
Flag Cleveland, TN
Thanks Meter: 1
 
More
Quote:
Originally Posted by Cryorus

Did you test it outside? It takes a while to get my location here at my work, but outside it is super fast.

I just did, and it worked!

I don't know how Google Maps can get a lock on my so easily while I'm inside, but Tasker struggles, haha. Perhaps Google Services it's using Google Service's last known location of me.
kitkat85
20th March 2016, 09:07 AM |#17  
Guest
Thanks Meter: 0
 
More
It's simpler to use GeoTask in order to get the address and location.
29th March 2016, 01:51 AM |#18  
Rythyrix's Avatar
Junior Member
Thanks Meter: 2
 
More
Big Brother now works for me. Thanks, MishaalRahman.

One thing to point out for paranoid/right peoplle, it is possible to make an email-to-SMS gateway trigger it, although it does require setting up a new Context.
For those who do not know, a SMS gateway is when you send an email to a carrier's portal, and they pass the message along as an SMS. It also works backwards, sending an SMS back will send the reply to the sending email address. Wikipedia has a list of U.S. ones. For those outside the U.S., some research will be required, so go practice your Google-fu.

One thing to check for is the message may be wrapped in transit with things like the sender's name, subject line, etc. Test it out thoroughly, as the Context's contents must match the SMS exactly in order to trigger the Task. I recommend sending the message and simply copy/pasting what it spits out as the new Context's contents.

Last caveat, check to make sure that the message actually comes through the email reply, AT&T's SMS-to-email parser breaks on the degree symbol (Unicode B0 ALT+0176 °), so some editing may be required on the receiving end prior to presenting the URL to Gmaps. Once again, test thoroughly.
2nd April 2016, 02:55 PM |#19  
Follow_and_Feel's Avatar
Senior Member
Flag Montabaur
Thanks Meter: 216
 
More
I don't know why, but I'm not able to import your projects into my tasker @MishaalRahman. Is there any way to export them in another format? Could you upload that? Is anyone else having this issue?

Would be awesome!

Cheers
21st May 2016, 08:31 PM |#20  
Junior Member
Thanks Meter: 0
 
More
I love the whole idea. It's great! Can you please write the Java scriptlet for me that works anywhere in the world? Requesting because I do not know coding at all.
14th December 2017, 07:32 PM |#21  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by Motofarer

I love the whole idea. It's great! Can you please write the Java scriptlet for me that works anywhere in the world? Requesting because I do not know coding at all.

Same here, on step 4 (JavaScriptlet) I can't understand what amendments I need to do so it changes to my country.

Thank you.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes