Created
June 12, 2023 19:21
-
-
Save jrgavilanes/faa2ae8f7e4525f11e4efd6a092270d7 to your computer and use it in GitHub Desktop.
ejemplo vue+materizalize+leaflet.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css"> | |
<title>Vue with Materialize CSS</title> | |
<style> | |
#map { | |
position: absolute; | |
top: 64px; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="app"> | |
<nav> | |
<div class="nav-wrapper"> | |
<a href="#" class="brand-logo">Logo</a> | |
<ul id="nav-mobile" class="right hide-on-med-and-down"> | |
<li v-for="item in menuItems" :key="item.id"> | |
<a :href="item.url" @click="showModal">{{ item.label }}</a> | |
</li> | |
</ul> | |
</div> | |
</nav> | |
<section class="section"> | |
<div class="container"> | |
<div id="map"></div> | |
</div> | |
</section> | |
<div id="modal" class="modal"> | |
<div class="modal-content"> | |
<h4>{{ modalMessage }}</h4> | |
</div> | |
<div class="modal-footer"> | |
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Close</a> | |
</div> | |
</div> | |
</div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.js"></script> | |
<script type="module"> | |
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js' | |
const miApp = createApp({ | |
data() { | |
return { | |
message: 'Hello Vue!', | |
modalMessage: 'yusaaaa', | |
menuItems: [ | |
{ id: 1, label: 'Home', url: '#' }, | |
{ id: 2, label: 'About', url: '#' }, | |
{ id: 3, label: 'Contact', url: '#' } | |
] | |
}; | |
}, | |
mounted() { | |
this.initMap(); | |
}, | |
methods: { | |
showModal() { | |
this.modalMessage = 'Hola'; | |
const modal = document.getElementById('modal'); | |
const instance = M.Modal.init(modal); | |
instance.open(); | |
}, | |
initMap() { | |
const map = L.map('map').setView([39.453058, -0.354405], 15); | |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | |
attribution: '© OpenStreetMap contributors' | |
}).addTo(map); | |
L.marker([39.454889, -0.352942]).addTo(map) | |
.bindPopup('Ciudad de las Artes y las Ciencias') | |
.openPopup(); | |
} | |
} | |
}).mount('#app') | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment