我有这段代码,我希望地理位置能够打开一个新窗口,该窗口直接指向它存储的数据的示例:它仅显示为(geolocation:https://www.google.com/maps/place/7.9911209,125.1280968)
中的文本这是我的代码:
const emergencyList = document.querySelector('#emergency-list');
const form = document.querySelector('#add-form');
function renderEmergencyList(doc) {
let li = document.createElement('li');
let name = document.createElement('span');
let accidenttype = document.createElement('span');
let geoloc = document.createElement('a');
let cross = document.createElement('div');
li.setAttribute('data-id', doc.id);
name.textContent = "Name: " + doc.data().user.fullname;
accidenttype.textContent = "Accident Type: " + doc.data().accident_type;
geoloc.textContent = "Geo Location: " + doc.data().geo_point;
cross.textContent = 'x';
li.appendChild(name);
li.appendChild(accidenttype);
li.appendChild(geoloc);
li.appendChild(cross);
emergencyList.appendChild(li);
// deleting data
geoloc.addEventListener('click', function() {
window.open(geo_point);
})
cross.addEventListener('click', (e) => {
e.stopPropagation();
let id = e.target.parentElement.getAttribute('data-id');
db.collection('Emergency Message').doc(id).delete()
})
}
<div id="content" class="content">
<a ul id="emergency-list" onclick="changeLink()">
<a href="" id="mylink"">Geolocation</a>
</ul>
</div>
这是输出,我希望地理位置可以在指向链接的新窗口中单击
名称:undefined
事故类型:它存储
地理位置:https://www.google.com/maps/place/7.9911209,125.1280968 *仅在*