This file contains 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
<template> | |
<div> | |
<form @submit.prevent="onSubmit"> | |
<label for="location">Localitat:</label> | |
<input | |
id="location" | |
type="text" | |
v-model="query" | |
@input="fetchLocations" | |
placeholder="Cerca localitats..." |
This file contains 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
<template> | |
<div id="map" style="height: 500px;"></div> | |
</template> | |
<script setup> | |
import { onMounted, ref } from 'vue'; | |
import 'leaflet/dist/leaflet.css'; | |
import L from 'leaflet'; | |
import locations from '@/services/location.js'; |
This file contains 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
// Para evitar problemas de CORS con las peticiones entre dominios distintos | |
add_action('init', 'handle_preflight'); | |
function handle_preflight() { | |
$origin = get_http_origin(); | |
if ($origin === 'https://midominio.com') { | |
header("Access-Control-Allow-Origin: midominio"); | |
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); | |
header("Access-Control-Allow-Credentials: true"); | |
header('Access-Control-Allow-Headers: Origin, X-Requested-With, X-WP-Nonce, Content-Type, Accept, Authorization'); |