kopia lustrzana https://github.com/paraboul/mapchecking
Add map search box
rodzic
85eb345996
commit
1d58dd1b88
|
@ -1,7 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
|
<div class="w-full h-full">
|
||||||
|
<input id="pac-input" class="controls" :class="[mapLoaded ? '' : 'hidden']" type="text" placeholder="Search Box">
|
||||||
<div class="w-full h-full" id="map"></div>
|
<div class="w-full h-full" id="map"></div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -36,9 +37,32 @@
|
||||||
lat: this.mapPosition[0],
|
lat: this.mapPosition[0],
|
||||||
lng: this.mapPosition[1]
|
lng: this.mapPosition[1]
|
||||||
},
|
},
|
||||||
mapTypeId: 'roadmap'
|
mapTypeId: 'roadmap',
|
||||||
|
gestureHandling: 'greedy'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const input = document.getElementById('pac-input');
|
||||||
|
const searchBox = new google.maps.places.SearchBox(input);
|
||||||
|
map.controls[google.maps.ControlPosition.LEFT_TOP].push(input);
|
||||||
|
|
||||||
|
searchBox.addListener('places_changed', () => {
|
||||||
|
var places = searchBox.getPlaces();
|
||||||
|
|
||||||
|
if (places.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var place = places[0];
|
||||||
|
|
||||||
|
map.setCenter(place.geometry.location);
|
||||||
|
map.setZoom(17);
|
||||||
|
|
||||||
|
this.reset();
|
||||||
|
});
|
||||||
|
|
||||||
|
map.addListener('bounds_changed', function() {
|
||||||
|
searchBox.setBounds(map.getBounds());
|
||||||
|
});
|
||||||
map.addListener('center_changed', this.mapUpdated);
|
map.addListener('center_changed', this.mapUpdated);
|
||||||
map.addListener('zoom_changed', this.mapUpdated);
|
map.addListener('zoom_changed', this.mapUpdated);
|
||||||
map.addListener('click', this.mapClicked);
|
map.addListener('click', this.mapClicked);
|
||||||
|
@ -46,7 +70,8 @@
|
||||||
map.setOptions({
|
map.setOptions({
|
||||||
draggableCursor:'crosshair',
|
draggableCursor:'crosshair',
|
||||||
clickableIcons: false,
|
clickableIcons: false,
|
||||||
disableDoubleClickZoom: true
|
disableDoubleClickZoom: true,
|
||||||
|
streetViewControl: false
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$map = map;
|
this.$map = map;
|
||||||
|
@ -72,6 +97,7 @@
|
||||||
this.updatePolygonColor();
|
this.updatePolygonColor();
|
||||||
|
|
||||||
this.$updateHashTimer = null;
|
this.$updateHashTimer = null;
|
||||||
|
this.mapLoaded = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -122,9 +148,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
mapClicked(ev) {
|
mapClicked(ev) {
|
||||||
const path = this.$poly.getPath();
|
this.$poly.getPath().push(ev.latLng);
|
||||||
|
|
||||||
path.push(ev.latLng);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
surfaceUpdated() {
|
surfaceUpdated() {
|
||||||
|
@ -220,7 +244,8 @@
|
||||||
return {
|
return {
|
||||||
mapPosition: [48.862895, 2.286978, 18],
|
mapPosition: [48.862895, 2.286978, 18],
|
||||||
surface: 0,
|
surface: 0,
|
||||||
arrPoly: []
|
arrPoly: [],
|
||||||
|
mapLoaded: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue