Chris

Forum Replies Created

Viewing 15 posts - 571 through 585 (of 1,120 total)
  • Author
    Posts
  • in reply to: Google map overlay on admin mappress area #13835
    Chris
    Keymaster

      Hi,

      From version 2.40.8 you can get the editor with:
      window.mappEditor

      You can get the current MapPress map object using:
      window.mappEditor.getMap().getMap();

      To get the *Google* map object use:
      window.mappEditor.getMap().getMap();

      in reply to: Conflict with the latest EVENT CALENDAR by Tri.be #13816
      Chris
      Keymaster

        Hi,

        Some conflicts are from programming errors, or sometimes two plugins are just incompatible.

        The current version of MapPress is stable and I’m not aware of it breaking any other plugins. As for Event Calendar breaking MapPress – I can’t guess why, but an explanation about what doesn’t work and a sample URL would help.

        My time for troubleshooting other plugins is limited, but if you’d like to also send a login to a demo site where I can see the issue and make modifications, I’ll take a look.

        in reply to: Custom Fields in PoiList #13810
        Chris
        Keymaster

          Hi,

          You can use the shortcode mashuptitle=”post” to show the post title in a mashup. The same setting is also on the plugin settings page.

          in reply to: POI markers – default sort order? #13805
          Chris
          Keymaster

            Alphabetical sorting is applied by default. Use sort=”false” in the shortcode to turn it off:

            [mappress sort="false"]

            Chris
            Keymaster

              The custom field names will be whatever field was saved by the form. You can check the database table wp_postmeta for a post that was saved to find the correct names – they usually don’t have spaces in them.

              If the address isn’t valid, or your server is over the Google geocoding limit, you won’t be able to geocode. In that case, the plugin will write a custom field called ‘mappress_errors’ with the error message in it.

              The before/after options are a convenience. You can put the shortcode [mappress] anywhere in your post.

              Chris
              Keymaster

                Hi,

                That’s not possible because the maps generated dynamically aren’t saved.

                I don’t know what you generate the maps from, but if you can generate them from custom fields in the post you can use the MapPress geocoding settings to automatically create a map for each post and save it. Then, the saved maps can be combined in a mashup normally.

                Chris
                Keymaster

                  Hi,

                  In your code, I don’t see you assigning a height. Also, have you checked the contents of $adresse_complete_resto_br? It may not be a valid address.

                  The geocoding function will return an instance if WP_Error if there’s an error, so you can check for that if needed.

                  Here’s an example that works for me:

                  
                  <?php
                  $mymap = new Mappress_Map(array("width" => 646, 'height' => 100));
                  $address = "30 chestnut street";
                  $mypoi_1 = new Mappress_Poi(array("address" => $address ));
                  $mypoi_1->geocode(); // Works for me
                  $mymap->pois = array($mypoi_1);
                  echo $mymap->display();
                  ?>
                  
                  Chris
                  Keymaster

                    Hi,

                    Can you provide a URL for your map?

                    I don’t think your POI has a location. You’ll need to geocode the address or provide a lat/lng in order to see a marker. See the documentation section ‘Geocoding with PHP’ if you need to geocode. Lat/lng can be done with:

                    $mypoi_1->point = array('lat' => 40, 'lng' => -74.1234);

                    in reply to: Mashup query with two custom fields #13781
                    Chris
                    Keymaster

                      Unfortunately, the WP query engine doesn’t provide support for more than one meta value in a query string. Multiple ‘meta_key’ or ‘meta_values’ are ignored (‘meta_value__and’ is also ignored, it’s not a valid keyword).

                      One workaround is to use a single value or a taxonomy instead. Or, a ‘save_post’ action can be used to set a single custom field value or category when the post is saved.

                      Another option is to create the map using PHP. If the query is passed as an array, WP allows complex mtea queries. You’ll need to add some code to your template:

                      <?php
                      	$query = array(
                      	'post_type' => 'any',
                      	'posts_per_page' => -1,
                      	'meta_query' => array(
                      		array('key' => 'color', 'value' => 'blue'),
                      		array('key' => 'size', 'value' => 'large'),
                      	)
                      );
                      $map = new Mappress_Map(array('query' => $query, 'width' => 400, 'height' => 400));
                      echo $map->display();
                      ?>

                      There are some meta query examples here:
                      http://codex.wordpress.org/Class_Reference/WP_Query

                      in reply to: MapPress Show Date and Category on Mashup Pop Ups #13777
                      Chris
                      Keymaster

                        Hi,

                        The WP functions that begin with ‘the_’ (like the_time) are really meant to work only on a global current post, in the theme’s “The Loop” section.

                        The mashup has its own query so the ‘the_’ functions won’t work. But there are two workarounds:

                        1) Find the corresponding WP function that uses a post or post ID instead. For example, instead of the_time(‘F’), call get_the_time(‘F’, $post_id) instead. Not all template functions have a clear analog, for example get_the_category() has to be replaced with get_the_terms().

                        2) Save the current post from The Loop, set up the mashup post, and then restore the current post. Then you can use ‘the_’ functions in the mashup.

                        Example code for #1:

                        <?php
                          $post = $poi->get_post();
                          if ($post) {
                        	echo get_the_time( 'F j, Y', $post) . "<br/>";
                        	$terms = get_the_terms( $post->ID, 'category');
                        	if (isset($terms[0]))
                        		echo $terms[0]->name;
                          }
                        ?>

                        Example for #2:

                        <?php
                          global $post;
                        
                          // Save current post from The Loop
                          $current_post = ($post) ? clone($post) : null;
                        
                          $post = $poi->get_post();
                          if ($post) {
                        	setup_postdata($post);
                        	echo the_time( 'F j, Y') . "<br/>";
                        	$categories = get_the_category();
                        	if (isset($categories[0]))
                        		echo $categories[0]->cat_name;
                        
                        	// Restore original post so we don't interfere with The Loop
                        	if ($current_post) {
                        		$post = $current_post;
                        		setup_postdata($current_post);
                        	}
                          }
                        ?>
                        Chris
                        Keymaster

                          Hi, I haven’t seen that behavior since some very old versions.

                          I couldn’t get it to happen for me on my test system. What exactly are you typing?

                          I tried this for example, but no error:
                          <a href="www.yahoo.com">yahoo</a>

                          Try deactivating your other plugins for a moment as well; it’s possible there’s a conflict.

                          in reply to: 100% map height? #13757
                          Chris
                          Keymaster

                            Hi,

                            The map actually is filling 100% of its parent element, but unless the parent has a fixed height the browser will report 100% height as zero (i.e. unknown).

                            Most blog themes don’t use a fixed height because the page is meant to scroll, so height=100% by itself won’t work.

                            To make a full-screen map you need to first create a full-screen theme template file.

                            As an example here are the steps for the standard 2013 theme:

                            1. Create a custom post type to hold your map.

                            2. Create a post using the new custom post type and put your map shortcode in it, for example: [mappress height="100%" width="100%"]

                            3. Create a new theme template file called “single-type.php” where ‘type’ is the post type you created in step 1. This will apply a special theme template file to just that post type (alternatively, there are some plugins that let you assign a template file to individual posts instead of a custom post type).

                            4. Edit the template file to make the content area full-screen. See below for a simple example in the 2013 theme. You can modify the example to add a header, sidebar, etc.

                            5. In your styles.css, tell the map layout to fill 100% of the screen:

                            .mapp-layout {
                              height: 100%;
                            }

                            6. If you want to display a poi list, use a shortcode with a partial height, for example height=”70%”, and adjust the styling of the poi list:

                            .mapp-poi-list {
                              max-height: 30%;
                            }

                            Here is a simple theme template file for “single-type.php”:

                            <!DOCTYPE html>
                            <!--[if IE 7]>
                            <html class="ie ie7" <?php language_attributes(); ?>>
                            <![endif]-->
                            <!--[if IE 8]>
                            <html class="ie ie8" <?php language_attributes(); ?>>
                            <![endif]-->
                            <!--[if !(IE 7) | !(IE 8)  ]><!-->
                            <html <?php language_attributes(); ?>>
                            <!--<![endif]-->
                            <head>
                            	<meta charset="<?php bloginfo( 'charset' ); ?>">
                            	<meta name="viewport" content="width=device-width">
                            	<title><?php wp_title( '|', true, 'right' ); ?></title>
                            	<link rel="profile" href="http://gmpg.org/xfn/11">
                            	<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
                            	<!--[if lt IE 9]>
                            	<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
                            	<![endif]-->
                            	<?php wp_head(); ?>
                            </head>
                            
                            <body <?php body_class(); ?>>
                            	<div id="page" class="hfeed site">
                            		<div id="main" class="site-main">
                            			<div id="primary" class="content-area">
                            				<div id="content" class="site-content" role="main">
                            					<div style="position: fixed; left: 0; right: 0; top: 0; bottom: 0; border: 5px solid red; overflow: hidden">
                            						<?php /* The loop */ ?>
                            						<?php while ( have_posts() ) : the_post(); ?>
                            							<?php the_content(); ?>
                            						<?php endwhile; ?>
                            					</div>
                            				</div><!-- #content -->
                            			</div><!-- #primary -->
                            		</div><!-- #main -->
                            	</div><!-- #page -->
                            	<?php wp_footer(); ?>
                            </body>
                            </html>
                            in reply to: POI Infobox auto height? #13756
                            Chris
                            Keymaster

                              Can you elaborate or provide a URL?

                              Infoboxes should automatically size based on the window content, so height:auto won’t do anything.

                              To check if you have a theme conflict, you can switch to the 2013 theme for a moment.

                              If you’re using infoWindows instead of infoBoxes, there’s a bug in the Google API that sizes them wrong. Star this issue to have Google fix it (they seem to prioritize by number of stars):

                              http://code.google.com/p/gmaps-api-issues/issues/detail?id=5713

                              in reply to: Geocode inside a CustomPostType #13741
                              Chris
                              Keymaster

                                Hi Connie,

                                The plugin doesn’t have any functionality to add geocoders in post editors.

                                But if you’re using MapPress to generate maps from the address, it is already geocoding each address into a lat/lng. With some PHP code you could capture those values and save them to custom fields.

                                I haven’t tested this code but it might help to get you started:

                                
                                <?php
                                function mysave($post_ID, $post) {
                                  // Get the first map & first poi for this post
                                  $maps = get_post_map_list($post->ID);
                                
                                  // Get first map and its first poi
                                  if (!empty($maps) && !empty($map[0]->pois)) {
                                	  $poi = $map[0]->pois[0];
                                      update_post_meta($post->ID, 'my_lat', $poi->point['lat']);
                                      update_post_meta($post->ID, 'my_lng', $poi->point['lng']);
                                  }
                                }
                                
                                add_action('save_post', array(&$this, 'save_post'), 110, 2);
                                
                                in reply to: Mashup map displays every POI from a single map #13736
                                Chris
                                Keymaster

                                  Hi,

                                  The license prohibits reselling the code but if you’d like to share add-on code with each other feel free – please email each other directly rather than posting here.

                                  I have a lot on my development list already so I don’t yet have plans to limit searching to only the first POI from a map (other than the filter I mentioned).

                                  I don’t know if it will work for you, but one workaround is to just use two different posts:

                                  Post A – the main post. Create a map with a single main searchable location here.
                                  Post B – a second post. Create the full map with all locations here.

                                  In Post A, add a shortcode to display the map from Post B using [mappress mapid=123]. When users view Post A, they will then see the full map. But for searches, only the single location that is actually attached to Post A will appear.

                                  Post B can be excluded from queries by assigning it to a custom post type, different category, etc.

                                Viewing 15 posts - 571 through 585 (of 1,120 total)