Skip to content
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

Map not Loading on the template #54

Closed
japhethmutai opened this issue Jul 13, 2019 · 10 comments
Closed

Map not Loading on the template #54

japhethmutai opened this issue Jul 13, 2019 · 10 comments

Comments

@japhethmutai
Copy link

Map doesn't load on the form as expected. I have tried this with the sample map in the app but it is working fine. Could there be any special requirement needed when using form wizard? I am trying to load the map on a form wizard, but I am not sure if that is the problem. Console gives me this as an error:

Uncaught TypeError: Cannot read property 'value' of null at Object.getExistingLocation (google-maps-admin.js:92) at Object.initialize (google-maps-admin.js:41) at HTMLDocument.<anonymous> (google-maps-admin.js:165) at j (jquery.min.js:2) at k (jquery.min.js:2)

I also noticed that another jquery.js is loaded, which is of lower version 3.1.0 as compared to the jquery loaded that is used in the project which is v3.2.1

@madisona
Copy link
Owner

@Chirie - could you post any code that shows more specifically what you are trying? Could this be the same issue as #53

@japhethmutai
Copy link
Author

Hello @madisona, sorry for taking long to respond to your response. After much digging, I realized that in the django-form-wizard, the form fields ids are named as id_{form_name}-address and id_{form_name}-geolocation. This breaks the google-maps-admin.js file since it is expecting the id in the form of id_address and id_geolocation. I changed this in the .js file to reflect the form field names and it worked. Problem is, now, it breaks other parts that I am using the google maps widget. Is there a way to fix this?

@madisona
Copy link
Owner

madisona commented Oct 5, 2019

hi @japhethmutai I'm not sure of a great way to make the field id a variable you could specify and be able to pass that to an external js file. I'd love to know if you come across a solution for it, as it would be helpful to allow someone to specify the field id's they wanted.

@MartinSchere
Copy link

Same issue here

@iryna-horbachova
Copy link

Screenshot 2020-10-27 at 21 08 48

Same! Does anyone know what to do with this? The code amlost entirely matches the one in the demo...

@madisona
Copy link
Owner

@iryna-horbachova

The script expects you've named your fields exactly like the example. The stack trace leads me to believe your geocode field may not have an id of id_geolocation.

image

@iryna-horbachova
Copy link

@iryna-horbachova

The script expects you've named your fields exactly like the example. The stack trace leads me to believe your geocode field may not have an id of id_geolocation.

image

Oh, thanks for your reply. So there is no way to have 2 geolocation in the same django model?

@madisona
Copy link
Owner

Hi @iryna-horbachova - that's right, you wouldn't be able to have multiples on the same model without modification.

@dmugtasimov
Copy link

dmugtasimov commented Apr 17, 2021

Similar happens if geolocation field made read-only (as recommended in the description):

@register(Store)
class StoreAdmin(ModelAdmin):
    list_display = ('name', 'address', 'geolocation')
    readonly_fields = ('geolocation',)
jquery.js:4046 jQuery.Deferred exception: Cannot read property 'value' of null TypeError: Cannot read property 'value' of null
    at Object.getExistingLocation (http://127.0.0.1:8001/static/django_google_maps/js/google-maps-admin.js:105:69)
    at Object.initialize (http://127.0.0.1:8001/static/django_google_maps/js/google-maps-admin.js:41:41)
    at HTMLDocument.<anonymous> (http://127.0.0.1:8001/static/django_google_maps/js/google-maps-admin.js:178:15)
    at mightThrow (http://127.0.0.1:8001/static/admin/js/vendor/jquery/jquery.js:3762:29)
    at process (http://127.0.0.1:8001/static/admin/js/vendor/jquery/jquery.js:3830:12) undefined
jQuery.Deferred.exceptionHook @ jquery.js:4046
jquery.js:4055 Uncaught TypeError: Cannot read property 'value' of null
    at Object.getExistingLocation (google-maps-admin.js:105)
    at Object.initialize (google-maps-admin.js:41)
    at HTMLDocument.<anonymous> (google-maps-admin.js:178)
    at mightThrow (jquery.js:3762)
    at process (jquery.js:3830)

Django 3.1.7

@madisona
Copy link
Owner

@dmugtasimov - the sample app admin.py shows how to make the geolocation field readonly and have it still work appropriately: https://github.com/madisona/django-google-maps/blob/master/sample/admin.py

dlenskyi pushed a commit to dlenskyi/django-google-maps that referenced this issue Oct 19, 2022
made frontend for bank export, added condition for e-conomic invoices…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants