[MUSIC PLAYING]
MANO MARKS: Hi, I'm Mano Marks.
Welcome to another edition of Google
Maps Developer Shortcuts.
Today, I'm going to talk to you about the Google Maps SDK
for iOS and using it with storyboards, so this will be a
really quick short shortcut.
Storyboards, as you probably know, are a powerful tool for
rapidly developing your user interface for iOS
applications.
Storyboards are in the latest versions of Xcode, so we're
just going to take a quick look at it.
There's a lot of people out there think that you can't use
storyboards with the Maps SDK, and those people are wrong.
So just a quick look here--
don't have time to do a full, like, these are storyboards,
but just taking a quick look at the storyboards here, you
see we have a table view controller, prototypes cell,
which I have used to create my segue, and the segue controls
what data gets sent to the next view.
And I simply dragged from control--
control dragged from the prototype cell in the table
view into my view controller over here which is where I
create my map.
So this view controller, which is just a standard view
controller that I dropped in here, and then I popped in my
class, MR Map View Controller, to load the map.
And in MR Map View Controller, I created an object MV.
You can actually see it's a GMS Marker Options object that
gets synthesized when it loads.
And here we have, in view did load, when that gets passed
in, that MV gets passed in, Add Marker With Options MV.
And it just grabs the position from the map view options, the
latitude and longitude, and then sets the
camera to that location.
Now how did I get here though?
If we go back to the MR View Controller, which is the
controller for the table view, I created a table with just
one cell, and that's Sydney, a a table data array.
Then I created another NS array of GS marker options,
added one in there.
And in the prepare for segue method, I have if the segue
identifier is equal to show map view, which it is, it
finds the index of the table view, the index path for
selected row.
And then it finds that row.
And then from the coordinate data array, which is the GMS
marker array, it passes that corresponding object over to
the map view.
And let's just take a look at what that looks like.
So this is my table with my simple one location, Sydney,
and you can see it shifts the map view over to
the map view there.
And the nice thing about this is it just handles quite
naturally on its own, the flow back and forth
between these two pages.
Now, if I take a look just at the View Controller, just to
prove to you that it did, when I originally load the map, I
create a camera position with latitude and
longitude, zero, zero.
So you can see that when it passes over the GMS Marker
Options object, it then uses that to find the current
location, and create a marker there.
So that's it.
That's our shortcut for today.
Hopefully, you are all out there creating iOS
applications, and if you use storyboards, it's a very
powerful tool to get you going.
So thanks for joining us, and see you next week.
[MUSIC PLAYING]