• Resolved Pawan Bagra

    (@bagrapk)


    Dear Friends,

    Please share the PHP code to use [covid-live-map sort="confirmed" height="250px"] code in directly in php. Also please tell us how to choose auto height & width.

    Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author M Media

    (@mmediagroup)

    Hey @bagrapk!

    Great questions! We’ve updated the plugin so you can do exactly this, so the following applies only to 1.4.7 and above.

    To use the live map in PHP, you can use the following code:

    <?php MMedia_Covid::shortcode_map(['sort' => 'confirmed', 'height' => '250px']); ?>

    Depending on what you are doing, you may need to echo or print the output to display the map.

    The width is determined by the parent container and for dynamic heights, we suggest passing vh values; 100vh corresponds to 100% of the vertical height of the browser window. This is known as a relative value and you can read more info if you’d like right here: https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#Relative_length_units

    You could also pass 100% height and just style the parent element to taste. This will give you the most control.

    Please note that the map defaults to showing the whole world, so if the width is smaller than the height of the contents of the map, then you will see white space at the top until the map is zoomed in. The default initial zoom isn’t currently controllable, so its best to make sure whatever element you’re creating has a ratio that is similar to that of a world map.

    I’m marking this closed, but feel free to message us here or open a new topic if you have any more questions!

    Thread Starter Pawan Bagra

    (@bagrapk)

    hi @mmediagroup thanx for your support.

    The code you provide is not working
    <?php MMedia_Covid::shortcode_map(['sort' => 'confirmed', 'height' => '250px']); ?>

    But I found the code, which is working
    <?php //echo do_shortcode( '[covid-live-map sort="confirmed" height="700px"]' ); ?>

    Isnt it possible if i use simply <?php MMedia_Covid::shortcode_map(['sort' => 'confirmed']); ?> or <?php //echo do_shortcode( '[covid-live-map sort="confirmed"]' ); ?>

    Plugin Author M Media

    (@mmediagroup)

    Hey @bagrapk!

    Well done on finding a solution.

    This should work – <?php echo MMedia_Covid::shortcode_map(['sort' => 'confirmed']); ?>. Make sure to add echo before (like I just did in this example ?? ), otherwise it won’t show it on the frontend.

    Let me know if this works!

    • This reply was modified 4 years, 11 months ago by M Media.
    Thread Starter Pawan Bagra

    (@bagrapk)

    Hi @mmediagroup

    Thank you for encouraging.

    The code <?php echo MMedia_Covid::shortcode_map(['sort' => 'confirmed']); ?> is working perfect.

    Once again thank you your plugin and support.

    Plugin Author M Media

    (@mmediagroup)

    Awesome @bagrapk!

    Very happy to hear ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP code’ is closed to new replies.