Send feedback
  
   
 
  
    
      Maps Service
    
    
      
      
      Stay organized with collections
     
    
      
      Save and categorize content based on your preferences.
     
   
     
  
  
  
   
  
  
    
      
  
  
    
      
        outlined_flag 
       
     
    
      
        
          The Maps service allows scripts to generate static maps, find directions, convert addresses to coordinates, and sample elevations.
         
      
        
          The service provides classes for finding directions, geocoding, sampling elevation, and creating static map images.
         
      
        
          Enums are available for defining restrictions to avoid in directions, map image formats, marker sizes, travel modes, and map types.
         
      
        
          You can create new instances of DirectionFinder, ElevationSampler, Geocoder, and StaticMap using the Maps class methods.
         
      
        
          Authentication for a Google Maps APIs Premium Plan account can be set to leverage additional quota allowances.
         
      
     
   
 
    
    
Maps 
This service allows scripts to generate static maps, find directions, convert
addresses into geocode coordinates, and sample elevations.
Classes 
Name Brief description 
 
Avoid An enum representing the types of restrictions to avoid when finding directions. 
 
Color An enum representing the named colors available to use in map images. 
 
DirectionFinder  Allows for the retrieval of directions between locations. 
 
DirectionFinderEnums   A collection of enums used by DirectionFinder   
 
ElevationSampler  Allows for the sampling of elevations at particular locations. 
 
Format An enum representing the format of the map image. 
 
Geocoder Allows for the conversion between an address and geographical coordinates. 
 
Maps Allows for direction finding, geocoding, elevation sampling and the creation of static map
images. 
 
MarkerSize  An enum representing the size of a marker added to a map. 
 
Mode An enum representing the mode of travel to use when finding directions. 
 
StaticMap  Allows for the creation and decoration of static map images. 
 
StaticMapEnums   A collection of enums used by StaticMap   
 
Type An enum representing the type of map to render. 
 
 
Properties 
Property Type Description 
 
TOLLSEnumAvoid tolls. 
 
HIGHWAYSEnumAvoid highways. 
 
 
 
Properties 
Property Type Description 
 
BLACKEnum 
BROWNEnum 
GREENEnum 
PURPLEEnum 
YELLOWEnum 
BLUEEnum 
GRAYEnum 
ORANGEEnum 
REDEnum 
WHITEEnum 
 
 
Methods 
Method Return type Brief description 
 
addWaypoint(latitude, longitude)  DirectionFinder  Adds a waypoint that the route must pass through, using a point (lat/lng). 
 
addWaypoint(address)  DirectionFinder  Adds a waypoint that the route must pass through, using an address. 
 
clearWaypoints()  DirectionFinder  Clears the current set of waypoints. 
 
getDirections()  ObjectGets the directions using the origin, destination, and other options that were set. 
 
setAlternatives(useAlternatives)  DirectionFinder  Sets whether or not alternative routes should be returned, instead of just the highest ranked
route (defaults to false). 
 
setArrive(time)  DirectionFinder  Sets the desired time of arrival (when applicable). 
 
setAvoid(avoid)  DirectionFinder  Sets whether to avoid certain types of restrictions. 
 
setDepart(time)  DirectionFinder  Sets the desired time of departure (when applicable). 
 
setDestination(latitude, longitude)  DirectionFinder  Sets the ending location for which to calculate directions to, using a point (lat/lng). 
 
setDestination(address)  DirectionFinder  Sets the ending location for which to calculate directions to, using an address. 
 
setLanguage(language)  DirectionFinder  Sets the language to be used for the directions. 
 
setMode(mode)  DirectionFinder  Sets the mode of travel (defaults to driving). 
 
setOptimizeWaypoints(optimizeOrder)   DirectionFinder  Sets whether or not to optimize the provided route by rearranging the waypoints in a more
efficient order (defaults to false). 
 
setOrigin(latitude, longitude)  DirectionFinder  Sets the starting location from which to calculate directions, using a point (lat/lng). 
 
setOrigin(address)  DirectionFinder  Sets the starting location from which to calculate directions, using an address. 
 
setRegion(region)  DirectionFinder  Sets a region to use when interpreting location names. 
 
 
 
Properties 
Property Type Description 
 
PNGEnum8-bit PNG format. 
 
PNG8Enum8-bit PNG format. 
 
PNG32Enum32-bit PNG format. 
 
GIFEnumGIF format. 
 
JPGEnumJPEG format. 
 
JPG_BASELINEEnumNon-progressive JPEG format. 
 
 
 
Properties 
Property Type Description 
 
TINYEnumTiny sized markets (smallest available). 
 
MIDEnumMedium sized markers (largest available). 
 
SMALLEnumSmall sized markers. 
 
 
 
Properties 
Property Type Description 
 
DRIVINGEnumDriving directions via roads. 
 
WALKINGEnumWalking directions via pedestrian paths and sidewalks (where available). 
 
BICYCLINGEnumBicycling directions via bicycle paths and preferred streets (where available). 
 
TRANSITEnumTransit directions via public transit routes (where available). 
 
 
 
Methods 
Method Return type Brief description 
 
addAddress(address)  StaticMap  Adds a new address to the current path definition. 
 
addMarker(latitude, longitude)  StaticMap  Adds a marker to the map using a point (lat/lng). 
 
addMarker(address)  StaticMap  Adds a marker to the map using an address. 
 
addPath(points)  StaticMap  Adds a path to the map using an array of points. 
 
addPath(polyline)  StaticMap  Adds a path to the map using an encoded polyline. 
 
addPoint(latitude, longitude)  StaticMap  Adds a new point (lat/lng) to the current path definition. 
 
addVisible(latitude, longitude)  StaticMap  Adds a point (lat/lng) location that must be visible in the map. 
 
addVisible(address)  StaticMap  Adds an address location that must be visible in the map. 
 
beginPath()  StaticMap  Starts a new path definition. 
 
clearMarkers()  StaticMap  Clears the current set of markers. 
 
clearPaths()  StaticMap  Clear the current set of paths. 
 
clearVisibles()  StaticMap  Clears the current set of visible locations. 
 
endPath()  StaticMap  Completes a path definition started with beginPath(). 
 
getAs(contentType)  Blob Return the data inside this object as a blob converted to the specified content type. 
 
getBlob()  Blob Gets the image data as a Blob  
 
getMapImage()   Byte[]Gets the raw image data as a byte array. 
 
getMapUrl()   StringGets the URL of the map image. 
 
setCenter(latitude, longitude)  StaticMap  Sets the center of the map using a point (lat/lng). 
 
setCenter(address)  StaticMap  Sets the center of the map using an address. 
 
setCustomMarkerStyle(imageUrl, useShadow)    StaticMap  Sets the custom marker image to use when creating new markers. 
 
setFormat(format)  StaticMap  Sets the format of the map image. 
 
setLanguage(language)  StaticMap  Sets the language to be used for text on the map (where available). 
 
setMapType(mapType)   StaticMap  Sets the type of map to be shown. 
 
setMarkerStyle(size, color, label)   StaticMap  Sets the marker style to use when creating new markers. 
 
setMobile(useMobileTiles)  StaticMap  Sets whether or not to use specialized tile sets for mobile devices. 
 
setPathStyle(weight, color, fillColor)   StaticMap  Sets the path style to use when creating new paths. 
 
setSize(width, height)  StaticMap  Sets the width and height of the map image in pixels. 
 
setZoom(zoom)  StaticMap  Sets the zoom factor, or magnification level, used for the map. 
 
 
 
Properties 
Property Type Description 
 
ROADMAPEnumA standard roadmap, as is normally shown on the Google Maps website. 
 
SATELLITEEnumA satellite map. 
 
TERRAINEnumA physical relief map, showing terrain and vegetation. 
 
HYBRIDEnumA hybrid of the satellite and roadmap maps, showing a transparent layer of major streets and
place names on the satellite map. 
 
 
 
 
  
  
     
  
    
    
      
    
     
  
       
         
  
  
    
    Send feedback
  
   
 
       
    
    
  
  
 
  Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
  Last updated 2024-12-03 UTC.
 
 
  
  
    
    
    
      
  
  
    Need to tell us more?
  
   
 
     
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-03 UTC."],[],[]]