• Resolved akinorikul

    (@akinorikul)


    I would like to display a map with some specific styling :

    `function custom_pronamic_google_maps_the_content( $content ) {
    $content .= pronamic_google_maps( array(
    ‘width’ => 955,
    ‘height’ => 400,
    ‘map_options’ => array(
    ‘styles’ => array(
    (object) array(
    ‘stylers’ => array(
    (object) array( ‘saturation’ => ‘-100’ ),
    )
    ),
    )
    )
    ) );

    return $content;
    }`

    I can find a way to write it as a shortcode, is it possible ?

    https://www.ads-software.com/plugins/pronamic-google-maps/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello akinorukul.

    Unfortunately the plugin doesn’t currently support setting the ‘styles’ with the shortcode. Instead what you could do is write your own shortcode and put the function you pasted over into that shortcode.

    Would that be an option?

    Thread Starter akinorikul

    (@akinorikul)

    Hello Leon,
    why not, I tried :

    function custom_pronamic_google_maps_the_content( $atts, $content=null ) {
            $content .= pronamic_google_maps( array(
                'width'  => 955,
                'height' => 400,
                'map_options' => array(
    				'styles' => array(
    					(object) array(
    						'stylers' => array(
    							(object) array( 'saturation' => '-100' ),
    						)
    					),
    				)
    			)
            ) );
    
            return $content;
        }
    
        //add_filter( 'the_content', 'custom_pronamic_google_maps_the_content', 9 );
        add_shortcode( 'custom_googlemaps', 'custom_pronamic_google_maps_the_content' );

    and used [custom_googlemaps] in my post but it doesn’t work.
    Am I missing something ?

    Plugin Author Remco Tolsma

    (@remcotolsma)

    You need to set ‘echo’ argument to false:

    function custom_pronamic_google_maps_the_content( $atts, $content=null ) {
            $content .= pronamic_google_maps( array(
                'echo'  => false,
                'width'  => 955,
                'height' => 400,
                'map_options' => array(
    				'styles' => array(
    					(object) array(
    						'stylers' => array(
    							(object) array( 'saturation' => '-100' ),
    						)
    					),
    				)
    			)
            ) );
    
            return $content;
        }
    
        //add_filter( 'the_content', 'custom_pronamic_google_maps_the_content', 9 );
        add_shortcode( 'custom_googlemaps', 'custom_pronamic_google_maps_the_content' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘shortcode with array (map options)’ is closed to new replies.