简体   繁体   English

在 iFrame 中显示纬度和经度标记值

[英]show Latitude and Longitude marker values in iFrame

I have a main HTML file (index.html) where i load a Map (OpenLayers) and each time a user click somewhere on the Map a marker is added and a Modal window will open with an iframe inside (iframe_content.html).我有一个主 HTML 文件 (index.html),我在其中加载地图 (OpenLayers),每次用户单击地图上的某个位置时,都会添加一个标记,并且会打开一个带有 iframe (iframe_content.html) 的模态窗口。 This iframe content file has a Form with many input fields and i want to show the Latitude and Longitude marker values in the correspondent input field.这个 iframe 内容文件有一个包含许多输入字段的表单,我想在对应的输入字段中显示纬度和经度标记值。

I'm a JavaScript noob but at the moment i already can grab those LonLat values and show them on a JS alert, so i guess i only need to figure it out how to "send" these values to the correspondent inputfield located in the other file «iframe_content.html».我是一个 JavaScript 菜鸟,但目前我已经可以获取那些 LonLat 值并在 JS 警报中显示它们,所以我想我只需要弄清楚如何将这些值“发送”到位于另一个的对应输入字段文件«iframe_content.html»。

Can you please give me some tips on this?你能给我一些关于这个的提示吗? Thanks in advance!提前致谢!

NC数控

在此处输入图片说明

When you load the modal you could have something like this:当您加载模态时,您可能会遇到这样的事情:

var iframe = document.getElementById('iframe_id');
var inner  = iframe.contentDocument || iframe.contentWindow.document;

Now if you have the fields as a name array:现在,如果您将字段作为名称数组:

var fields  = inner.getElementsByName('fields[]');

Or get them by the id:或者通过 id 获取它们:

var lat_field  = inner.getElementsById('latitude');
var lon_field  = inner.getElementsById('longitude');

Now just set the value of the fields to the value you want in this case the coordinates:现在只需将字段的值设置为您想要的值,在这种情况下为坐标:

fields[0].value = coordinate['latitude'];
fields[1].value = coordinate['longitude'];

Or with the ids:或者使用 ID:

lat_field.value = coordinate['latitude'];
lon_field.value = coordinate['longitude'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel和谷歌地图:foreach纬度/经度显示标记或地图 - Laravel and google maps : foreach latitude/longitude show marker or map 当标记之一是 null 经度和纬度时,leaflet map 不显示所有标记 - leaflet map doesn't show all the marker when one of the marker is null longitude and latitude 如何通过使用htlm和Java脚本从Firebase数据库检索的纬度和经度在地图上显示标记 - How to show a marker on map by using latitude and longitude retrieved from firebase database in htlm and java script 在InfoWindow中显示Google Maps标记的经度和纬度 - Displaying latitude and longitude of Google Maps marker in InfoWindow 在传单中查找已保存标记的纬度和经度 - find latitude & longitude of saved marker in leaflet 在反应传单中获取标记的纬度和经度 - Getting latitude and longitude of a marker in react-leaflet Leaflet 动画标记不显示经纬度 - Leaflet animated marker not displaying the latitude and longitude 我需要获取标记的纬度和经度 - I need to get the latitude and longitude of my marker 在标记点击事件上显示纬度和经度 - Displaying Latitude and Longitude on Marker click event 如何在一个 map 中显示 3 个纬度和经度(标记)? - how to display 3 latitude & longitude (Marker) in one map?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM