Screen markers are 2D markers that follow a location on the globe or map. As the user moves, they move, but they don’t get any bigger or smaller.
We’ll need an XCode project here, so if you haven’t done the Hello Earth tutorial go do that. If you haven’t got one yet, here’s a suitable ViewController (for Objective-C or Swift).
Markers don’t have to have images, they can be just color, but no one does that. You’ll want a suitable image. It so happens we have a selection available.
Look in the maki icons directory within the resources. We’re going to use the image called alcohol-shop-24@2x. You can just search for that filename.
When you find it, add it to your HelloEarth project. Be sure its part of the HelloEarth target.
Now that we’ve got the perfect icon, let’s put it somewhere.
Politicians are big drinkers, so let’s toss a few of those icons on world capitals. Add the following method to your ViewController.
And don’t forget to run it by adding this to your viewDidLoad method.
And thus we get… bars!
Astute observers will point out that not all of those are world capitals. Don’t bother, I’m an American and thus ignorant of geography.
Let’s take a closer look at what we did there. The capitals themselves are obvious enough. We just create a MaplyCoordinate, which is in radians from degrees, which the rest of you find more intuitive. Weirdos.
For each marker, we just set the location, assign the image and the size. The size is in screen pixels and won’t vary. Then we add each marker to an array and hand them over as a group.
The reason we add the markers all at once is performance. WhirlyGlobe-Maply needs that hint to batch them all together. There are some exceptions to this, but in general the toolkit is batching based on what you hand it. And batching is good.