Git Product home page Git Product logo

Comments (6)

caioariede avatar caioariede commented on August 10, 2024

@MikeSandford did you try trigger change event?

from django-location-field.

MikeSandford avatar MikeSandford commented on August 10, 2024

@caioariede thanks for taking a look at this! I just tried change, keyup, focusout and blur.

$("#id_location").val(loc_string).change().focusout().blur().keyup();

I also tried manually inputting 0,0 and when I clicked away from the input the map and marker didn't update that way either. It seems as though there's a binding from the "watched" form inputs to the map, but not from the actual lat/lon input to the map.

from django-location-field.

MikeSandford avatar MikeSandford commented on August 10, 2024

@caioariede I was able to put together some code that does the latlong input field to map marker binding and it works on my local machine. But then I went down the rabbit hole a little bit looking at leaflet docs and it seems like there's stuff in leaflet to do exactly that! map.locate is available and you can even pass in a watch=true parameter.

I can make a PR with what I already have but I'm not entirely sure what's the best route forward here. Are you interested in adding this capability? If so do you have a preference on how it's achieved? The one difficulty I have on attempting to expose the leaflet functionality is that I'm not sure how to get a reference to the map from the context of a webpage that has a button on it that a user presses to center the map on themselves. I can find the jQuery node that's the div of the map widget or the inner div of the actual rendered map but I haven't figured out how to get something that I can then call any of the $.locationField methods on.

from django-location-field.

Alsaheem avatar Alsaheem commented on August 10, 2024

hello @MikeSandford please im havin gthe same issue , how do i fix it ,....

Thanks

from django-location-field.

pfcodes avatar pfcodes commented on August 10, 2024

+1

from django-location-field.

michaelhjulskov avatar michaelhjulskov commented on August 10, 2024

Solution would be to trigger a change on the city field or one of the other fields, "its" listening to.

Example if you have jQuery

after you have changed the value of location input field - then trigger a change on the city field

loc_string = ?something?
$("#id_location").val(loc_string);
$("#id_city").trigger('change');

or maybe you should trigger keyup on the city field - you'll have to look in the code to see or just play around with it.

I think that will do the trick for you :)

from django-location-field.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.