通过用户定义的坐标嵌入Google-Maps iFrame

时间:2015-08-07 13:10:06

标签: javascript jquery html google-maps iframe

我目前正在一个网站上工作并遇到一个小问题。我希望用户能够在Google Map上选择COORDINATES。所以我在我的网站上嵌入了一个Maps-Iframe,当用户点击一个按钮时,地图的中心坐标(以及缩放,倾斜和地图类型)将保存在一些变量中。没问题,直到这里。

现在我希望能够为iFrame创建HTML以显示Map。我应该解释一下,它用于在线富文本编辑器(自制) - 它应该能够在谷歌地图iframe上保存一个选定的视图。

我有中心坐标,倾斜度,缩放级别,地图类型 - 当用户点击按钮后,当他决定要保存当前的谷歌地图位置时,保存在变量中的所有内容。如何获取iFrame的HTML?我想要这样的JavaScript代码不起作用...你知道,只是一些HTML可以像任何其他文本一样保存:

<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='https://www.google.at/maps/@" + CenterCoordinates['G'] + "," + CenterCoordinates['K'] + "," + Zoom + "z,output=embed'></iframe>

这就是现在的样子:

enter image description here

当用户点击Google-Maps-iFrame下方的按钮时,应保存当前的视图,并且应创建具有完全相同坐标,缩放,倾斜,maptype的iFrame并将其插入到可信的iframe中。单击按钮后调用的函数仅执行此操作:

RichTextField.document.execCommand("insertHTML", false, "<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='https://www.google.at/maps/@" + CenterCoordinates['G'] + "," + CenterCoordinates['K'] + "," + Zoom + "z,output=embed'></iframe>");

0 个答案:

没有答案