I'm trying to manipulate the admin map after it is loaded however I cannot get a reference to the map. I've set NO_GLOBAL to false, and my template to override the admin template is as follows.
This logs "undefined", but if I load the page, open the console, and run the exact same code I get a reference to the map, and can then add markers as needed. Am I going about this the wrong way? Should I be able to get a reference to the map this way?
I've tried placing the script tag into the admin_change_form_document_ready block.
I've also tried the following with the same results.
Edit:
It appears the issue is that the map is not initialized by the time var map = window['leafletmapid_location-map']; runs. If I run it in an event listener after a button click it works, but it is in the scope of the listener function.
I cannot find anyway to get a reference to the admin map in the global scope of my template. Is there anyway to accomplish this?
I'm trying to manipulate the admin map after it is loaded however I cannot get a reference to the map. I've set NO_GLOBAL to false, and my template to override the admin template is as follows.
Template:
This logs "undefined", but if I load the page, open the console, and run the exact same code I get a reference to the map, and can then add markers as needed. Am I going about this the wrong way? Should I be able to get a reference to the map this way?
I've tried placing the script tag into the admin_change_form_document_ready block.
I've also tried the following with the same results.
Edit: It appears the issue is that the map is not initialized by the time var map = window['leafletmapid_location-map']; runs. If I run it in an event listener after a button click it works, but it is in the scope of the listener function.
I cannot find anyway to get a reference to the admin map in the global scope of my template. Is there anyway to accomplish this?