1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-23 14:59:36 +02:00

Add clear map function

This commit is contained in:
Sean Morley 2024-08-23 14:24:30 -04:00
parent b11c3de461
commit f75c650a20
2 changed files with 15 additions and 2 deletions

View file

@ -16,13 +16,13 @@ class CountrySerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Country model = Country
fields = '__all__' # Serialize all fields of the Adventure model fields = '__all__' # Serialize all fields of the Adventure model
read_only_fields = ['id', 'name', 'country_code', 'continent', 'flag_url', 'geometry'] read_only_fields = ['id', 'name', 'country_code', 'continent', 'flag_url']
class RegionSerializer(serializers.ModelSerializer): class RegionSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Region model = Region
fields = '__all__' # Serialize all fields of the Adventure model fields = '__all__' # Serialize all fields of the Adventure model
read_only_fields = ['id', 'name', 'country', 'name_en'] read_only_fields = ['id', 'name', 'country', 'name_en', 'geometry']
class VisitedRegionSerializer(serializers.ModelSerializer): class VisitedRegionSerializer(serializers.ModelSerializer):
class Meta: class Meta:

View file

@ -101,6 +101,13 @@
} }
} }
function clearMap() {
console.log('CLEAR');
markers = [];
region_id = null;
region_name = null;
}
let imageSearch: string = adventure.name || ''; let imageSearch: string = adventure.name || '';
async function removeImage(id: string) { async function removeImage(id: string) {
@ -298,6 +305,9 @@
if (data.in_region) { if (data.in_region) {
region_name = data.region_name; region_name = data.region_name;
region_id = data.region_id; region_id = data.region_id;
} else {
region_id = null;
region_name = null;
} }
} }
@ -637,6 +647,9 @@
bind:value={query} bind:value={query}
/> />
<button class="btn btn-neutral -mt-1" type="submit">Search</button> <button class="btn btn-neutral -mt-1" type="submit">Search</button>
<button class="btn btn-neutral -mt-1" type="button" on:click={clearMap}
>Clear Map</button
>
</form> </form>
</div> </div>
{#if places.length > 0} {#if places.length > 0}