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

Embed google maps #439

Closed
Yerlix opened this issue Apr 9, 2014 · 2 comments
Closed

Embed google maps #439

Yerlix opened this issue Apr 9, 2014 · 2 comments

Comments

@Yerlix
Copy link

Yerlix commented Apr 9, 2014

I can't show a map properly
I followed the documentation (http://www.deluxeblogtips.com/meta-box/how-to-display-google-map-in-the-front-end/) but it didn't work.

My code for the meta box:

 // List of meta fields
        'fields' => array(
            // HEADING
            array(
                'type' => 'heading',
                'name' => __( 'Google Map One Detail', 'rwmb' ),
            ),
            array(
                'id'            => 'address-one',
                'name'          => __( 'Address', 'rwmb' ),
                'type'          => 'text',
            ),
            array(
                'id'            => 'loc',
                'name'          => __( 'Location', 'rwmb' ),
                'type'          => 'map',
                'style'         => 'width: 500px; height: 500px',
                'address_field' => 'address-one',                     // Name of text field where address is entered. Can be list of text fields, separated by commas (for ex. city, state)
            ),
        )

This works good.

My code for showing the map:

 $args = array(
                    'type'         => 'map',
                    'width'        => 640, // Map width, default is 640px
                    'height'       => 480, // Map height, default is 480px
                    'zoom'         => 14,  // Map zoom, default is the value set in admin, and if it's omitted - 14
                    'marker'       => true, // Display marker? Default is 'true',
                    'marker_title' => '', // Marker title when hover
                    'info_window'  => '<h3>Info Window Title</h3>Info window content. HTML <strong>allowed</strong>', // Info window content, can be anything. HTML allowed.
                );
                echo rwmb_meta( 'loc', $args ); // For current post

This doesn't work.

I've also tried this:

 $address = rwmb_meta( 'address-one' );
                $location = rwmb_meta( 'loc' );

                if ( !empty( $address ) && !empty( $location ) )
                {
                    ?>
                    <?php if ( !empty( $location ) ) : ?>
                        <iframe frameborder="0" scrolling="no" src="https://maps.google.com/maps?hl=vi&amp;q=<?php echo $address; ?>+(<?php the_title_attribute(); ?>)@<?php echo $location; ?>+&amp;output=embed"></iframe>
                    <?php endif; ?>
                    <?php
                }

Which works, but not as I wanted. the first method can produce what I need, the second can't do this that easily.

@Yerlix
Copy link
Author

Yerlix commented Apr 14, 2014

The solution is to add pixels or percent to the width and height. Otherwise the plugin doesn't know what to do with it

@rilwis
Copy link
Member

rilwis commented Apr 28, 2014

Correct, we need to add 'px' after width and height. I'll correct the docs.

Thanks!

@rilwis rilwis closed this as completed Apr 28, 2014
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

2 participants