Get short Google Map URL to share in iOS - ios

I have latitude, longitude of the center of map view and zoom of the view. How can I generate the URL like this https://goo.gl/maps/twqcy in iOS? So that I can send my friend message like this: "Please go to this place: https://goo.gl/maps/twqcy".
I searched for the answer, and here is what I got: I can build a string like:
https://www.google.com/maps/place/#20.982375,105.7903495,17z to send to my friends.
However, there are 2 issues:
1) When user tap/click in the link, I want to show a marker. Currently it only center at the point with certain zoom degree that I put in. How can I generate a link, so that when my friend click on the link, he will see a marker?
2) How to change the form of the url to shortened one i.e from https://www.google.com/maps/place/#20.982375,105.7903495,17z to https://goo.gl/maps/twqcy.
Please answer with code in iOS, preferably in Swift.
UPDATE: This answer my question: Get url shortened with Google API, AFNetworking in Swift

returns directly a shortened NSURL
https://github.com/H2CO3/Shortener/blob/master/NSURL+Shortener.m

Related

Hubot display url as link in Slack

I'm using hubot with the hubot-slack adapter.
I have a very long url that I'd like to write to the chatroom, and would like to display it as a link.
From this:
http://magnum-ci.oak.domain.com:8080/job/nick_test_success_build/44/console
To this:
Click here to view the console out
I'm using:
res.send "http://magnum-ci.oak.domain.com:8080/job/nick_test_success_build/44/console|link"
I haven't tried this recently with Hubot, but note that it doesn't work as a user.
Slack's docs make it look like you can use "labels" to display friendly URL names. See the last example on this page https://api.slack.com/docs/unfurling
You may be able to send the text
<http://mylink.com|Show this>
in a message and get the desired results.
I tried this a long time ago and don't remember if it worked.
#mshish is right, <http://mylink.com|Show this> should be the way to go.
You can test the output of your link using the Message Builder.
Unfortunately it looks like this is not currently supported by the hubot.
https://github.com/slackhq/hubot-slack/issues/114

Google Maps sdk with voice navigation direction in IOS?

I´ve been reading the documentation of the Google Maps SDK for iOS and I didn't see anything about voice navigation direction and route on the map.
Do anyone know about this?
I correct my previous answer this is possible. You use the google directions API as outlined in this link:
You send your direction request and it returns the directions either as json or xml as per your preference. Gives you coordinates of each point on the route.
You send a request to http://maps.googleapis.com/maps/api/directions/outputformat?parameters
So if you want to return the directions as json the request would be:
http://maps.googleapis.com/maps/api/directions/json?origin=ORIGIN_LOCATION&destination=DESTINATION_LOCATION&sensor=FALSE
the ORIGIN_LOCATION and DESTINATION_LOCATION can either be a latitude and longitude seperated by a comma e.g. latitude,longitude or a location search string e.g Eiffel+Tower+,+Paris+France (The search string has to be url encoded).
The sensor parameter is another compulsory parameter and asks whether the device sending the request can detect its own location.
For example for the directions from the eiffel tower to the louvre museum are given on the following link as json:
http://maps.googleapis.com/maps/api/directions/json?origin=Louver+museum+Paris&destination=Eiffel+Tower+Paris+France&sensor=false
And to return it as XML:
http://maps.googleapis.com/maps/api/directions/xml?origin=Louver+museum+Paris&destination=Eiffel+Tower+Paris+France&sensor=false

twitter search api no place returned

I am having a bit of trouble sifting through the twitter API. I am trying to search for tweets near a certain location and then see their exact (or approximate) geo coordinates. I understand the geo field is deprecated and now we are supposed to use the "place" field. Unfortunately when I use the following url: http://search.twitter.com/search.json?q=&geocode=30.1829,-97.832,10mi I get a bunch of responses with a location that matches the city of the geo coordinates, but geo: is null and there is no place field. Am I stuck with only having an accuracy up to city coordinates, or am I using the wrong search call?
Thanks in advance!
Remember, tweeting with a geo location is an opt-in process. Twitter will supply a feed from the area for all tweeters in that area, but only those who have opted to tweet their coordinates will show up with "geo" info.
Using q=here with your url it did return 1 tweet for me with "geo" info in this form (though likely it will have moved on down the timeline by the time you try...):
"geo":{"coordinates":[-33.9769,18.5080],"type":"Point"}
Every user has a user defined location set in their profile settings. Use this when users don't use geo-encoding.
You can obtain a list of all countries / states by country and do a simple clean-up operation on the dataset.
This gave me what I needed for location data and greatly enriched my output.

twitter: share link with parameters

I have a share button on my site.
But I need to share link with parameters, and each time parameters will be different (I need to track user who is sharing, etc.)
For example need to share link like http://mySite.com/page?userId=111&someParam=222
I can share this well, but how can I force count to work correct?
if I set
data-url="http://mySite.com/page?userId=111&someParam=222"
data-counturl="http://mySite.com/page/"
I am getting count 0 always. How to get this work?
From http://dev.twitter.com/pages/tweet_button,
"The count box shows how many times the URL has been Tweeted."
Your problem is you simply have the url and counturl mixed up. Change url to the short one, for display purposes - that's the one people will see. Use the counturl for the one with all the parameters, to ensure they go to the right place with the parameters intact.
I suspect the reason your count kept showing zero tweets is because you have a different (unique) url as your primary url each time it is tweeted, so each tweet is the first time that url (including its parameters) was shared.
Twitter now lets you send the url through data attributes. This works perfectly for me and should work for you out of the box!
The button (check out data-url):
Tweet
The twitter javascript snippet (from https://dev.twitter.com/docs/tweet-button)
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

URL for multiple markers in Google Maps

In a desktop Qt application, I have some GPS coordinates that I'd like to show on a map. My plan is to construct an URL with the coordinates and let a web browser and Google maps or a similar service do the heavy lifting.
After reading some apparently reverse-engineered documentation at
mapki.com slash wiki slash Google_Map_Parameters
I can make it work for a single point, but what's the URL syntax for multiple points?
My best shot so far is to build a string such as this:
http://maps.google.com/?ie=UTF8&q=My+First+Point#59.591,17.82&q=My+Second+Point#59.592,17.82
but that will only show "My Second Point". Is there a better description of the syntax somewhere?
Replacing q= with markers= did not work and the "static map" suggestion below only complained about an incorrect API key.
for google maps static there is this URL:
http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap
&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318
&markers=color:red|label:C|40.718217,-73.998284&sensor=false&key=MAPS_API_KEY
Detailed version:
http://maps.google.com/maps/api/staticmap?
center=Brooklyn+Bridge,New+York,NY
&zoom=14
&size=512x512
&maptype=roadmap
&markers=color:blue|label:S|40.702147,-74.015794
&markers=color:green|label:G|40.711614,-74.012318
&markers=color:red|label:C|40.718217,-73.998284
&sensor=false
&key=MAPS_API_KEY
i am not sure if this syntax is also good for standard maps
http://staticmapmaker.com/ - very nice web tool for generating static map urls.
List of currently supported map services:
- Google
- Bing
- Yandex
- HERE
- Mapbox
- MapQuest
- CartoDB
p.s. I know this is an old question, but many still google for it.
Throwing parameters at maps.google.com only gets you one point.
As dusoft says, you could use Google Static maps.
Or, if you require dynamic maps, you could write your own public web page that uses Google Maps API and accepts a long list of parameters. Use your own web page in exactly the same way that you were intending to use maps.google.com web page, except that you get to design what you want the parameters to look like.
Perhaps something like this.
Several parameters (such as the markers and path parameters) take multiple locations. In those cases, the locations are separated by the pipe (|) character.
https://maps.googleapis.com/maps/api/staticmap?center=boca+raton,+fl+|+deerfied,+FL&zoom=12&scale=false&size=600x300&maptype=roadmap&sensor=false&key=API_KEY&format=png&visual_refresh=true&markers=size:mid%7Ccolor:red%7Cboca+raton,+fl+|+deerfied,+FL" alt="Google Map of boca raton, fl | deerfied, FL
I know that you specifically asked for Google Maps, however I came up with a solution using Bing Maps:
https://bing.com/maps/default.aspx?sp=point.48.858303_2.3499404_Eiffel%20Tower~point.48.8530067_2.3499404_Notre-Dame%20Cathedral~point.48.8605088_2.3376727_Louvre link
The sp parameter can define a list of points, polylines, polygons and addresses. Multiple objects are separated by ~.
The syntax for point is:
point.latitude_longitude_titleString_notesString_linkURL_photoURL
titleString is displayed in the map and notesString only when clicking on a point.
A Link with you coordinates would look like:
https://bing.com/maps/default.aspx?sp=point.59.591_17.82_P1~point.59.592_17.82_P2 link
I did some tests on how many of these points can be in a URL by generating a really long URL in the form of https://www.bing.com/maps?sp=point.10.000000_10.000000_0~point.10.000000_10.01_1~point.10.000000_10.02_2~point.10.000000_10.03_3... and it seems up to about 150 points are working.
Documentation:
Microsoft Documentation: Create a Custom Map URL

Resources