duan0504 2017-03-07 05:56
浏览 41
已采纳

在电子邮件中显示Google地图[重复]

This question already has an answer here:

I have the following code in my email template:

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3022.6173606180814!2d-73.98784413488774!3d40.74844444332261!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c259a9aeb1c6b5%3A0x35b1cfbc89a6097f!2sEmpire+State+Building%2C+350+5th+Ave%2C+New+York%2C+NY+10118!5e0!3m2!1sen!2s!4v1488865918048" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

I used yiiMailer in order to send mails to the users, and I have the following code in my controller:

$topic='Message';
$letter = $this->renderPartial('application.views.mail.email_temp',array('model'=>$model, 'topic'=>$topic, ''),true);
$message=$letter;
$mail = new YiiMailer('contact',array('message'=>$message));
$mail->setSubject('Message');

But, when I open the sent email, it is not showing Google Maps (tested with Gmail). How can I show Google Maps in my email?

</div>
  • 写回答

1条回答 默认 最新

  • drruhc4944 2017-03-07 06:13
    关注

    You can't get JavaScript maps working in email, and Gmail won't let you embed an iframe to an email. (iFrames and JavaScript added to an email in this way would be considered a security risk.)

    What you can do, however, is embed a static map image on your email.

    1. Go to http://staticmapmaker.com/google/ and enter location wanted.

    2. Copy the generated static map image and paste it the email.

    3. Copy the href from the "Map with link to Google Maps" section.

    4. Select the image you copied/pasted into your email and do command/ctrl+k to add a link to that image.

    5. Paste the url from step #3 into Web Address field.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 BV260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序