<head>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDmr2x0FWWydp93kDtbO3tgadydoc9bQVc&callback=initMap">
</script>
</head>
<h3>Mapa sencillo con marcador</h3>
<p id="parrafo">En este ejemplo, situamos la sede de la URJC en la Plaza de Manuel Becerra</p>
<div id="map"></div>
<!-- En el head hace la llamada a la API
El parámetro callback ejecuta la función initMap cuando se ha cargado la API
Los atributos async y defer permite que se siga renderizando la página mientras se carga la API
La key hace la llamada mediante la API Key para acceder al servicio
-->
function initMap() {
var urjc = {lat: 40.42747138327575, lng: -3.669160008430481};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 18,
center: urjc
});
var marker = new google.maps.Marker({
position: urjc,
map: map
});
}
/*
Creamos una función que inicializa y añade el mapa, con los siguientes elementos:
- Una variable que inicializamos con las coordenadas que centrarán el mapa
- Una variable que crea el objeto mapa, utiliza el método getElemenById y le pasa dos propiedades: center y zoom (escala: cuanto más bajo, más general)
Creamos una variable para incluir el marcador, inicializándola con el objeto marcador, y dos propiedades: position y map
*/
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.