Open Street Map inside Ajax Generated Bootstrap Modal - Displays Empty Container

Support General Open Street Map inside Ajax Generated Bootstrap Modal - Displays Empty ContainerResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #45381
    CodogCodog
    Participant

    Hi There,
    I've been trying to display the OSM Map inside an Ajax generated Bootstrap 5 Modal. The OSM map can be seen in the DOM but visually displays nothing (An empty Container? IE: No Marker and No map?).

    My Map is located inside a PHP template like this:

         
    $post = get_post($_POST['post_id']);                   
    $args = [
             'width'        => '100%',
             'height'       => '480px',
             'zoom'         => 17,
             'marker'       => true,
             ];
    rwmb_the_value( 'my_map', $args, $post->ID);
    

    This template is then called inside an Ajax function that shows it inside a dynamically generated bootstrap 5 Modal. All other elements within this template are called and display correctly. What am I missing for the OSM?

    FYI - What I see in the DOM:

    <div class="rwmb-osm-canvas" data-osm_options="{'latitude':'51.5034927','longitude':'-0.12770540128799','width':'100%','height':'480px','marker':true,'marker_title':','info_window':','js_options':{'zoom':17},'zoom':17}" style="width:100%;height:480px"></div>

    I look forward to your response 🙂

    #45393
    PeterPeter
    Moderator

    Hello,

    When a map is rendered, Meta Box loads some script files (CSS, JS) to display the map. The issue is when you call the template via Ajax, the script files aren't loaded and you won't see the map.

    Refer to this topic https://wordpress.stackexchange.com/questions/298969/enqueue-script-dinamically

    You can try to add some HTML tags like <script> <link rel="stylesheet" in the template and see if it helps. You can find the script files in the file wp-content/plugins/meta-box/inc/fields/osm.php.

    If you cannot complete the task, we offer a customization service with an extra fee. Please contact us here for more details.

    #45402
    CodogCodog
    Participant

    Hi Peter,
    thanks! Thought this was likely the case but wanted to check first. Thanks for your time 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.