Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update map marker with current location on the map #146

Closed
jlariza opened this issue Oct 8, 2020 · 0 comments
Closed

How to update map marker with current location on the map #146

jlariza opened this issue Oct 8, 2020 · 0 comments

Comments

@jlariza
Copy link

jlariza commented Oct 8, 2020

Good day,

We are using the library with this configuration

LOCATION_FIELD = {
    "map.provider": "openstreetmap",
    "search.provider": "nominatim",
}

The model is using a PlainLocationField.

We need to allow the users to use their current location in the map. For this, we implemented this little script

  function getLocation() {
    if ("geolocation" in navigator) {
      navigator.geolocation.getCurrentPosition(showPosition, error);
    } else {
      $("#location-message").show()
    }
  }
  function showPosition(position) {
    $("#id_location").val(position.coords.latitude + "," + position.coords.longitude)
  }
  function error(err) {
    $("#location-message").show()
  }

it is working fine, the latitude and longitude is automatically updated; however, the marker is not. How may we force the marker to move to the new coordinates?

We tried editing the coordinates directly and it is not working either; it seems that the marker updates the coordinates field but it does not work in the other way.

Thank you,

Repository owner locked and limited conversation to collaborators Apr 4, 2023
@caioariede caioariede converted this issue into discussion #166 Apr 4, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant