Skip to content

refreshMap only updates markers #113

@LukeSavefrogs

Description

@LukeSavefrogs

Problem

I would expect the following code to refresh all polygons in the map, not only markers:

// Update the form with the GeoJSON data
$set('geojson', json_encode($geoJsonData));
$set('location', [
    'geojson' => $geoJsonData,
    'lat' => $geoJsonData["features"][0]["geometry"]["coordinates"][0][0][1] ?? null,
    'lng' => $geoJsonData["features"][0]["geometry"]["coordinates"][0][0][0] ?? null,
]);

Log::debug('GeoJSON imported successfully:' . json_encode($get('location')));
$livewire->dispatch('refreshMap');

Instead, only the position of the view (based on lat and lng) actually changes.

Note

If I refresh the page after saving the data to the database everything works as expected and I get to see the polygons.

Cause

This behaviour is most probably due to the refreshMap method only triggering the marker and position updates:

refreshMap: function() {
this.map.flyTo(this.getCoordinates());
this.updateMarker();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions