Is there no way to embed a Google Map into an HTML email?

后端 未结 4 1831
刺人心
刺人心 2020-12-15 03:16

I have done a good amount of research and have found several \"solutions\" such as the static maps API and simply sending a link to a Gmap. However is there really no way to

4条回答
  •  萌比男神i
    2020-12-15 03:53

    yes there is a way using php and javascript you can pass static map url and pass it through form submission and use in email

    Get current location/ Coordinates through javascript

    var latlon = position.coords.latitude + "," + position.coords.longitude; var img_url = "https://maps.googleapis.com/maps/api/staticmap?center="+latlon+"&zoom=17&size=500x250&sensor=false&key=API_KEY&maptype=roadmap&markers=icon:http://maps.google.com/mapfiles/ms/icons/red-dot.png|"+latlon;
    

    here pass the value to input field

    document.getElementById("map_image").value = img_url;
    

    Inside form take input with id=map_image and type hidden than submit form and handle post request on next page

    than for handling after submission of form

    $map_image_url = $_POST['map_image'];
    

    than you can use this as img in email template

    $EMAILTEMPLATE .= '';
    

提交回复
热议问题