Skip to content

get LngLat in map #21

Closed
Closed
@akenore

Description

@akenore

hi,
i have use json_serializer = serializers.get_serializer("json")()
to get LngLat in javascript of the map to show marker on map but i have this error after i add a variable
to the code
Uncaught Error: LngLatLike argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]
because we can't have the longitude and latitude separated we get it like that (12.550343, 55.665957)
so in the Mapbox don't work do you have a possibility to separate what is in database like lng = 12.550343 and lat = 55.665957
that it can work in map
this is the code that I use to show in map

<script> var LngLat = '{{ partie.terrain }}'; var map = new mapboxgl.Map({ container: 'map', style: 'mapbox://styles/mapbox/satellite-streets-v11', center: [12.550343, 55.665957], zoom: 18 }); console.log(LongLat); var marker = new mapboxgl.Marker() .setLngLat(LongLat) .addTo(map); </script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions