Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ With this, the map view will automatically be centered on the result geometry, a

## Developing

To develop this plugin, it is recommended to set up a test app according to the instructions below, and use [npm link](https://docs.npmjs.com/cli/v10/commands/npm-link). When that is setup properly, use
To develop this plugin, an example has been set up in `example/`. To run the example with dynamically built plugin, run

npm run watch

to automatically update the linked package in the test application.
npm run dev:example
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default [
rules: {
'no-unused-vars': 'off',
'import/no-dynamic-require': 'warn',
'import/no-unresolved': 'off',
},
},
];
13 changes: 13 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="light dark">
<title>Vue Place Search</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="./src/main.js"></script>
</body>
</html>
51 changes: 51 additions & 0 deletions example/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<v-container class="d-flex justify-center align-center">
<v-card>
<v-card-title>OpenLayers Map</v-card-title>
<v-toolbar class="pr-1" density="compact">
<v-spacer /><place-search
/></v-toolbar>
<v-sheet class="fill-height">
<div ref="mapContainer" class="map"></div>
</v-sheet>
</v-card>
</v-container>
</template>

<script setup>
import 'ol/ol.css';
import '../../dist/style.css';
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import { onMounted, ref } from 'vue';
import { PlaceSearch, usePlaceSearch } from '../../dist/vue-place-search.js';

const mapContainer = ref(null);

const map = new Map({
layers: [
new TileLayer({
source: new OSM(),
}),
],
view: new View({
center: [0, 0],
zoom: 2,
}),
});

usePlaceSearch(map);

onMounted(() => {
map.setTarget(mapContainer.value);
});
</script>

<style>
.map {
width: 600px;
height: 400px;
}
</style>
20 changes: 20 additions & 0 deletions example/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'vuetify/styles';
import { createVuetify } from 'vuetify';
import App from './App.vue';
import { createApp } from 'vue';
import { aliases, mdi } from 'vuetify/iconsets/mdi-svg';

const vuetify = createVuetify({
icons: {
defaultSet: 'mdi',
aliases,
sets: {
mdi,
},
},
});

const app = createApp(App);
app.use(vuetify);

app.mount('#app');
5 changes: 5 additions & 0 deletions example/src/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import vuetify from './vuetify';

export function registerPlugins(app) {
app.use(vuetify);
}
18 changes: 18 additions & 0 deletions example/src/plugins/vuetify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* plugins/vuetify.js
*
* Framework documentation: https://vuetifyjs.com`
*/

// Styles
import 'vuetify/styles';

// Composables
import { createVuetify } from 'vuetify';

// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
export default createVuetify({
theme: {
defaultTheme: 'dark',
},
});
34 changes: 34 additions & 0 deletions example/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Vue from '@vitejs/plugin-vue';
import Vuetify, { transformAssetUrls } from 'vite-plugin-vuetify';

// Utilities
import { defineConfig } from 'vite';
import { fileURLToPath, URL } from 'node:url';
import { join, resolve } from 'node:path';

const root = fileURLToPath(new URL('.', import.meta.url));

// https://vitejs.dev/config/
export default defineConfig({
root,
plugins: [
Vue({
template: { transformAssetUrls },
}),
Vuetify(),
],
define: { 'process.env': {} },
resolve: {
extensions: ['.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
},
server: {
port: 3000,
},
css: {
preprocessorOptions: {
sass: {
api: 'modern-compiler',
},
},
},
});
79 changes: 50 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"preview": "vite preview",
"prepublishOnly": "npm run build",
"watch": "nodemon --watch src -e js,json,mjs,vue --exec 'npm run build'",
"dev:example": "npm run watch & vite -c example/vite.config.mjs",
"test": "npm run lint && npm run typecheck",
"lint": "eslint .",
"typecheck": "vue-tsc --noEmit"
Expand All @@ -58,6 +59,7 @@
"vue-tsc": "^2.0.21"
},
"peerDependencies": {
"@mdi/js": "^7.4.47",
"@types/geojson": "^7946.0.14",
"ol": "*",
"vue": "^3.0.0",
Expand Down
Loading