Class Map

java.lang.Object
  extended by Map

public class Map
extends java.lang.Object

A helper class that fetches a Google map for a specific location as an Image. Example of use:

 public class MapActor extends Actor
 {
     Map map;
     public MapActor() 
     {
         map = new Map("Brazil");
         setImage(map.getImage());
     }
     
     public void act() 
     {
         map.zoomIn(1);
         setImage(map.getImage());
     }
     
     public void setType(String type) 
     {
         map.setType(type);
         setImage(map.getImage());
     }
 }
 


Constructor Summary
Map(java.lang.String location)
          Constructs a map object that build a map of a specific location, e.g."-15.800513, -47.91378" or "Brooklyn Bridge, New York, NY".
Map(java.lang.String location, int width, int height, int zoom)
          Constructs a map object that build a map of a specific location, e.g."-15.800513, -47.91378" or "Brooklyn Bridge, New York, NY".
 
Method Summary
 greenfoot.GreenfootImage getImage()
          Returns the map represented as GreenfootImage.
 void setType(java.lang.String type)
          Sets the type of the map as one of: "roadmap" (the default), "satellite", "hybrid" or "terrain".
 void setZoom(int value)
          Sets the zoom factor insuring it is in the range [0-20].
 void zoomIn(int value)
          Increases the zoom factor.
 void zoomOut(int value)
          Decreases the zoom factor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Map

public Map(java.lang.String location)
Constructs a map object that build a map of a specific location, e.g."-15.800513, -47.91378" or "Brooklyn Bridge, New York, NY". The width and height fields will be set to default values as 600 x 400. The zoom field will be set to default as 5.

Parameters:
location - the location represents the center the map.

Map

public Map(java.lang.String location,
           int width,
           int height,
           int zoom)
Constructs a map object that build a map of a specific location, e.g."-15.800513, -47.91378" or "Brooklyn Bridge, New York, NY".

Parameters:
location - the location represents the center the map.
width - the image's width.
height - the image's height.
zoom - the zoom factor of the map [0-20].
Method Detail

setZoom

public void setZoom(int value)
Sets the zoom factor insuring it is in the range [0-20].

Parameters:
value - the zoom factor.

getImage

public greenfoot.GreenfootImage getImage()
Returns the map represented as GreenfootImage.

Returns:
GreenfootImage of the map.

setType

public void setType(java.lang.String type)
Sets the type of the map as one of: "roadmap" (the default), "satellite", "hybrid" or "terrain".

Parameters:
type - the type of the map.
Throws:
if - the passed parameter is not one of the predefined types.

zoomIn

public void zoomIn(int value)
Increases the zoom factor.

Parameters:
value - the change of the zoom factor.

zoomOut

public void zoomOut(int value)
Decreases the zoom factor.

Parameters:
value - the change of the zoom factor.