You are viewing an older version of MapQuest.js. Check out the latest version.
<html>
<head>
<script src="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.js"></script>
<link type="text/css" rel="stylesheet" href="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.css"/>
<script type="text/javascript">
window.onload = function() {
L.mapquest.key = '8nIoYUx9GyjZsdehJySzjprSvZIqgM42';
var popup = L.popup();
var map = L.mapquest.map('map', {
center: [38.890385, -77.031989],
layers: L.mapquest.tileLayer('map'),
zoom: 14
});
map.addControl(L.mapquest.control());
map.on('click', function(e) {
popup.setLatLng(e.latlng).openOn(this);
L.mapquest.geocoding().reverse(e.latlng, generatePopupContent);
});
function generatePopupContent(error, response) {
var location = response.results[0].locations[0];
var street = location.street;
var city = location.adminArea5;
var state = location.adminArea3;
popup.setContent(street + ', ' + city + ', ' + state);
}
}
</script>
</head>
<body style="border: 0; margin: 0;">
<div id="map" style="width: 100%; height: 530px;"></div>
</body>
</html>