2

I need to send HTML email to customer which contains Google maps (with directions) using java script or c# Example: Uber Call taxi sends to customer invoice with google maps as html mail Uber Html Invoice with google maps

DInesh AG
  • 316
  • 4
  • 20

3 Answers3

1

You can use Google Static Maps: https://developers.google.com/maps/documentation/static-maps/

An example would be something like this:

<img src="http://maps.googleapis.com/maps/api/staticmap?size=800x600&maptype=hybrid&scale=2&format=png8&sensor=false&path=geodesic%3Atrue%7C-6.9325%2C+37.3916666666667%7C-6.9325%2C+37.3933333333333%7C-6.93388888888889%2C+37.3933333333333%7C-6.93388888888889%2C+37.3916666666667%7C-6.9325%2C+37.3916666666667&zoom=10" width="800" height="600"/>
Rob Gates
  • 275
  • 5
  • 14
  • No, i am expecting to show directions between two location but Google static maps API not supporting directions. – DInesh AG May 02 '16 at 05:46
0

You can use the screen capture feature of PhantomJs to capture html page and save it as .jpg or .png image on a server. Then you can include the image in your invoice that you send out to users. PhantomJs commands can be saved as a .bat file and triggered via C# code.

TejSoft
  • 3,213
  • 6
  • 34
  • 58
0

There's a way to use the static API and add in an additional encoded polyline.

Example url here results in the following image:

Example image

Basically you have to generate a dynamic JS map and parse the result looking for a tag called "overview_polyline". This field is then sent in to the static map generator to add the line on top of the map.

Source: https://stackoverflow.com/a/23937276/1581477

More info on polylines: https://developers.google.com/maps/documentation/utilities/polylineutility

Community
  • 1
  • 1
Martin
  • 1,916
  • 2
  • 25
  • 37
  • In your scenario we must have n - number of latitude and longitudes it is not possible with only two latitude and longitudes(source location to destination) – DInesh AG May 02 '16 at 06:17
  • @DIneshAG I'm not sure I follow you here. What is it you want to have n number of? Previously you wrote "...show directions between two locations" which would work with my answer above. – Martin May 02 '16 at 06:22
  • In your Url static map api Path is encoded so the encoded path contains nearly 20 latitude and longitudes, see in your URL link "size=400x400&path=enc". Example after enc in url embedded like this "" – DInesh AG May 02 '16 at 06:37