Search code examples
google-maps-static-api

drawing a path between two cities on google static map


I want to draw a path between two cities on a google static map along a road according to a suggested route of google map.when I used path attribute with pipe characters I can draw a line but not along a road. for drawing it along a road suggested by google map what should i do?is that possible on google static map?


Solution

  • You can definitely do this with the Static Maps API:

    get directions using DirectionsService:

    http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsService

    and convert the overview path to suit the requirements of the Static Maps API:

    http://code.google.com/apis/maps/documentation/staticmaps/#Paths