You can add a variety of 3D shapes to a globe or even a map. We’ll start with a simple one, spheres.
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).
Like everything else, spheres have a location on the globe (or map). We’ll need some locations to use. If you’ve been through the Screen Markers tutorial these will be familiar.
We’ll also need a bit of logic to add the spheres, though that’s not too hard. Let’s look at some code. Add this to your ViewController.
Also add this to your viewDidLoad method to run it.
Go ahead and run it and you should get something like this.
So spheres! Let’s see how that works.
In the end, this isn’t too tricky. We create a MaplyShapeSphere, give it a location and size. That number for sizes is a little odd.
In WhirlyGlobe-Maply sizes like this are in display space. That’s based on the earth with a radius of 1.0 and all sizes are relative to that. If you want meters, just multiply by the radius of the earth in meters.
We add each of those spheres to an array and then create the spheres in the view controller all at once. This is for performance.
The description dictionary contains one entry for color. We’re making these spheres a little transparent and red. Because that looks cool, really.