<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
<div id="map"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
var map;
function json(){
$.getJSON('https://maps.googleapis.com/maps/api/geocode/json?address=C+AMADO+CAMARENA,1597,COL+BEATRIZ+HERNANDEZ,44760&key=AIzaSyD0RmYAcrA1mI_0gIX8N8qZHbvoHxzA1kQ',function(json){
console.log(json.results[0].geometry.location.lat);
var lat =json.results[0].geometry.location.lat;
var lng =json.results[0].geometry.location.lng;
console.log(lat);
initMap(lat,lng);
})
}
function initMap(lat,lng) {
var myLatlng = {lat:lat, lng:lng};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: myLatlng
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Click to zoom'
});
map.addListener('center_changed', function() {
// 3 seconds after the center of the map has changed, pan back to the
// marker.
window.setTimeout(function() {
map.panTo(marker.getPosition());
}, 3000);
});
marker.addListener('click', function() {
map.setZoom(8);
map.setCenter(marker.getPosition());
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD0RmYAcrA1mI_0gIX8N8qZHbvoHxzA1kQ&callback=json"
async defer></script>