Reply To: Zoom levels not working with Satellite maps + Formidable

Home Forums MapPress Support Zoom levels not working with Satellite maps + Formidable Reply To: Zoom levels not working with Satellite maps + Formidable

#15182
invisionstudios
Participant

The code is generating a map based on a Formidable form input, so it’s different each time. This is all generated using a Formidable View. Based on your request, I took a look at the code and discovered it was passing ‘null’ as zoom.

I just took a look at the ‘form_to_mappress’ code that I loaded in my theme’s functions.php file and saw that it wasn’t passing any sort of zoom or tilt level. I fixed it by adding values to the shortcode array and to the map output:

<?php

/* SHORTCODE FOR MapPress + Formidable Pro connection */
add_shortcode('form_to_mappress', 'form_to_mappress');
function form_to_mappress($atts) {
     extract(shortcode_atts(array(
	      	'width' => 425, 
		'height' => 350,
		'title' => '', 
		'body' => '',
                'address1' => '', 
		'address2' => '', 
		'directions' => 'none',
		'zoom' => 20,
		'tilt' => 45
     ), $atts));

     $mymap = new Mappress_Map(array('width' => $width, 'height' => $height));
     $mypoi_1 = new Mappress_Poi(array('title'=>$title, 'body'=>$body, 'address'=> $address1));
     $mypoi_1->geocode();
     $mymap->pois = array($mypoi_1);
     if($address2 != ''){
       $mypoi_2 = new Mappress_Poi(array('address' => $address2));
       $mypoi_2->geocode();
       $mymap->pois = $mypoi_2;
     }
     return $mymap->display(array('directions' => $directions, 'zoom' => $zoom, 'tilt' => $tilt));
}
/* END SHORTCODE MapPress */

Now it’s outputting exactly what I want, a close-up view of a specific property address input by the user. If there isn’t a 45 degree tilt view, it defaults to overhead, but the zoom level is exactly what I want.

Thanks for your assistance. Great support, as always!