Annotations can also be customized to give the user a better indication of what your location symbolizes. For example, if you are mapping the restaurants in a particular area, you may provide each annotation with an icon that symbolizes the type of restaurant it is—it can be a pizza slice for Italian food, a pint for pub food, or a hamburger for a fast food chain.
In this recipe, we will add a start button to the first pin and a stop button to the second, which we will use to control our exercise timer later on.
After your annotation is declared but before it is added to your mapView
object, type in the following code to create a custom leftButton
and a custom rightButton
. You should do the same for both the start location pin and the end location pin:
//add an image to the left of the annotation annotation.leftButton = 'images/location.png'; //add the start button annotation.rightButton = 'images/start.png';...