1. It's time to see a
MapField
in action! Add the following code to thecreateFields
method.MapField map = new MapField(); Coordinates c = new Coordinates(37.821582,-122.479362,(float) 0.0); map.moveTo(c); map.setZoom(4); add(map);
2. After that is done, compile and run the application and you will see a lovely map on the screen!
Again, because this is a read-only field the code is once again pretty simple compared to the ListField
and TreeField
that we just went over. Creating the field itself is very simple and setting up the field isn't much harder. In this sample, you create a Coordinates
object with the coordinates for the Golden Gate Bridge in San Francisco, California. As you can see, these coordinates are hardcoded, meaning you aren't using a GPS to get them.
Coordinates c = new Coordinates(37.821582,-122.479362,(float) 0.0);
Next, a call to the moveTo
method tells the MapField
to shift the display so that those coordinates are...