我有一个将谷歌位置转换为谷歌坐标(lat / lng)的脚本,效果很好。
我的结果打印到带有td和tr的表格中。直到现在,一切都很好。 但我想将结果(坐标)也打印到HTML中的另一个位置。
我希望结果也会打印到XXXX中的表格中。也可选择位置......
这对我不起作用......
function getResultsListItem(resultNum, resultDescription) {
var html = '<a onclick="selectMarker(' + resultNum + ')">';
html += '<div class="info" id="p' + resultNum + '">';
html += '<table><tr valign="top">';
html += '<td style=""><img src="' + getMarkerImageUrl(resultNum) + '"/></td>';
html += '<td style="">' + resultDescription + '</td>';
html += '</tr></table>';
html += '</div></a>';
return html;
}
/**
* Get suggestions for a postcode with multiple localities.
* @param {!google.maps.GeocoderResult} resultDescription Geocoding result.
*/
function getPostcodeLocalitiesSuggestion(resultDescription) {
if (resultDescription.types.indexOf("postal_code") == -1) return "";
console.log(resultDescription.postcode_localities.length + " localities");
var postcode = resultDescription.address_components[0].long_name;
var html = '<span class="dym">Did you mean</span>: ' + '<span class="pc_localities">' + postcode + ' in ';
for (i in resultDescription.postcode_localities) {
var locality = resultDescription.postcode_localities[i];
html += '<a href="#' + escape(getPermalink(postcode + ' ' + locality)) + '">';
html += locality + '</a>';
html += (i == resultDescription.postcode_localities.length - 1 ? '.' : ', ');
}
return html;
}
/**
* Get a nicely formatted result description.
* @param {!google.maps.GeocoderResult} result Geocoding result.
*/
function getResultDescription(result) {
var bounds = result.geometry.bounds;
var html = '<table class="tabContent">';
html += tr('Address', result.formatted_address);
if (result.postcode_localities) {
html += tr('Localities', result.postcode_localities.join('<br/>'));
}
html += tr('Types', result.types.join(", "));
html += tr('Location', result.geometry.location.toString());
html += tr('Bounds', (bounds ? boundsToHtml(bounds) : "None"));
html += tr('Viewport', boundsToHtml(result.geometry.viewport));
html += tr('Location type', result.geometry.location_type);
if (result.partial_match) {
html += tr('Partial match', 'Yes');
}
html += '</table>';
return html;
}
包含位置和名称的HTML ...
<table width="90%" border="0">
<tr>
<td>Foto: *</td>
<td>
<input type="file" id="bestand" name="bestand">
</td>
</tr>
<tr>
<td>Boxname: *</td>
<td>
<input type="text" id="boxname" name="boxname">
</td>
</tr>
<tr>
<td>User: *</td>
<td>
<input type="text" id="user" name="user">
</td>
</tr>
<tr>
<td>Country: *</td>
<td>
<select name="categorie" id="categorie">
<option value=""> - Gelieve een Land te kiezen - </option>
<option value="<?php echo $categorie['categorie_id']; ?>">
<?php echo $categorie['naam']; ?>
</option>
</select>
</td>
</tr>
<tr>
<td>Location: *</td>
<td>
<textarea id="location" name="location"></textarea>
</td>
</tr>
<tr>
<td>Coordinates: *</td>
<td>
<textarea id="coordinates" name="coordinates"></textarea>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" id="knop" name="knop" value="Add New Suezbox">
</td>
</tr>
</table>