google maps update no
maps lat lng elv in infowindow. on click.
by grant
HTML
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<div id="Gmap">
</div>
<div>click to set the marker</div>
<div id="lat"> </div>
<div id="lng"> </div>
<div id="mts"></div><span id="x"></span>
CSS
html,
body,
#map-canvas {
margin: 5px;
padding: 0;
height: 10%;
}
#Gmap {
margin: 0;
padding: 0;
height: 260px;
width: 260px;
}
#mts {
display: inline;
}
#x {
display: inline;
}
JavaScript
//http://jsfiddle.net/t2pdoq2t/1/
// https://stackoverflow.com/questions/32011058/google-map-lat-lng-on-loaded-points
var iconBase = 'https://lrio.com/kml/icons/';
var icons = {
Rapid: {
icon: iconBase + 'water.png'
},
Access: {
icon: iconBase + 'boat-ramp.png'
},
Surf: {
//icon: iconBase + 'info-i_maps.png'
icon: iconBase + 'surfing2.png'
},
Quail: {
icon: iconBase + 'quail.png'
}
};
function load() {
var map = new google.maps.Map(document.getElementById("Gmap"), {
center: new google.maps.LatLng(41.784, -73.319),
zoom: 9,
mapTypeId: 'roadmap'
});
// ga
var infoWindow = new google.maps.InfoWindow();
// Change this depending on the name of your PHP file
// downloadUrl("phpsqlajax_genxml.php", function (data) {
var xml = parseXml(xmlStr); // data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
// var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
// var latlng = markers[i].getPosition();
var latitude = markers[i].getAttribute("lat");
var longitude = markers[i].getAttribute("lng");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
// bounds.extend(point);
var html =
"<div >Latitude: <input type='text' id='lat' value='" + latitude + "'/> </div>" +
"<div >Longitude: <input type='text' id='lng' value='" + longitude + "'/> </div>" ;
// var html = "<b>" + name + "</b> <br/>" + address + "<br/>" + type + "<br/>" + latitude +...