Forum Replies Created
-
AuthorPosts
-
Hi,
I’ve just published version 2.53, which includes an option on the MapPress setting screen to select the geocoder you’d like to use.
Algolia is built on OpenStreetMap data, but it turns out it doesn’t do street number geocoding, even if it’s available on OSM. In other words, it will just show the middle of the nearest street, even if OSM has more specific data. That’s why the address “383 Woodbury Ave, Portsmouth, NH 03801” works on OSM but not in Algolia.
OSM itself seems to have spotty street-level data. It worked for some areas I tried, but not others. You can use the OSM geocoder called Nominatim by selecting it on the settings screen.
I’ve also added a MapBox option. Their geocoder seems to be more accurate.
Be sure to read the geocoders terms of use for usage limits and other restrictions – there are links to them in the MapPress documentation.
I tried many other geocoders, but most are based on OSM, and thus are no better than Nominatim. There is one called geocod.io, which looks useful. They are free and seem to be accurate, but only cover the USA.
I didn’t implement geocod.io yet because I wasn’t sure anyone needs it. But if you, or anyone else, would like to have geocod.io (or any other geocoder), added to MapPress, please let me know.
June 6, 2019 at 4:43 am in reply to: Automatic repositioning of info bubble not working on some maps #18349Hi,
I think you’ve narrowed this down to an error with Query Monitor, but please let me know if you think it’s a bug in MapPress. If so, it’d be helpful to have a URL where I can see the problem.
Hi,
As far as I know, it’s not possible to maps to delete themselves. However, one thing that is sometimes confusing is that the maps are attached to the post where they are created and not the post to where they are displayed.
Is it possible the missing map was actually created in a different post, but displayed in the post which remains?
Hi,
I couldn’t see the image. A URL would be more useful, do you have one you can share? You can use the contact form or email if you don’t want to post it here.
Maybe specify the last argument ‘single’ = true for get_post_meta, otherwise I think it will return an array:
https://developer.wordpress.org/reference/functions/get_post_meta/
Hi
I see a few small problems in the filter & template:
1) For the filter, you begin by appending to $html, but it’s not defined yet. So replace:
$html .= '<span class="price label label-warning">';
with:
$html = '<span class="price label label-warning">';
2) In the template, I’d suggest using ‘<span>’ instead of ‘i’. Also, when you use two braces the HTML is escaped – i.e. the returned HTML from the filter was being escaped. Use 3 braces instead, which outputs the value without modifying it:
<h3>{{{poi.title}}}</h3> {{{poi.thumbnail}}} <br /> <ul class="infos"> <# if (poi.props.annonce_surface) { #> <span class="fal fa-home" aria-hidden="true"></span> {{poi.props.annonce_surface}} m² <# } #> <span class="fal fa-bed" aria-hidden="true"></span> {{poi.props.annonce_chambres}} chambre(s) <span class="fal fa-bath" aria-hidden="true"></span> {{poi.props.annonce_sdb}} SDB {{{poi.props.prix}}} €Hi,
Can you share your popup template? I’m wondering if maybe the error is there.
Hi,
Have a look at the MapPress settings screen in the ‘POI Click’ section, I think ‘Open post’ may be what you want.
Hi,
I don’t know what the problem is, but I can’t test with your data. One thing I can suggest is just to return some text and make sure it’s displaying in the template. Once you get that working you can try to debug the other code.
For example, replace this:
$props['prix'] = $html;
with:
$props['prix'] = 'TESTING';
Once that’s working, you can add the other lines one by one to find the problem.
Yes, but you would use your calculation to return the value. It would look something like this (this is just pseudo-code – I haven’t tested it):
function myfilter($props, $postid, $poi) { $price = annonce_detail('annonce_prix'); $html = number_format( $price, 0, ',', ' ' ) . ' € '; if ( has_term( 'location', 'offre' ) ) $html .= '<small>/ mois</small>'; if ( has_term( 'location-saisonniere', 'offre', $postid ) ) $html .= '<small>/ nuit</small>'; $props['prix'] = $html; return $props; }Hi,
Have you read the documentation yet? There’s an example there of using the PHP filter to pass a value to the template.
In this case, you would use that filter to pass the result of your function to the template as a property, then display that property in the template.
I’m not sure if it’s clear, but PHP code can’t be used for calculation in the template itself. The templates use JavaScript, and they only execute when a popup is displayed.
So, using has_term() in the template won’t do anything useful. Instead, you need to do the calculations for each post using the mappress_poi_props filter. The results are then passed to the template for display using the poi.props array.
There’s an example of using the filter to pass a custom value to the template here in the MapPress documentation:
https://mappresspro.com/mappress-documentation/#toc-mappress-templating
Hi,
The templates are editable via the MapPress settings screen. They’re saved in your theme directory, and the originals are in the /templates directory of the plugin. There’s general information about this in the MapPress documentation.
I think you are asking to display a field only if non-empty. For that, you would need some javascript in the template. You can do a simple if statement by using three braces:
{{{ (poi.props.annonce_surface) ? poi.props.annonce_surface : 'empty'}}}Or, make a conditional block using ‘<#’ and ‘#>’ around the JavaScript parts:
<# if (poi.props.annonce_surafce) { #> <i class=””fal” aria-hidden=””true””></i> {{poi.props.annonce_surface}} m² <# } #>It’s worth a try adding the business name. OSM is also free (their geocoder is called ‘Nominatim’). I think Algolia was built on an OSM data extract several years ago, maybe it hasn’t been updated?
MapBox also worked for me when I tried the sample address. There are other geocoders that are paid but have generous free usage limits. I haven’t tried them myself, but here’s a couple if you want to have a look:
Hi,
I think I see the problem: you have two meta_key/meta_values. That’s not possible in the shortcode (it’s a limitation of the WP query module when using strings). You can only use one meta. If possible, convert the non-numeric key to a tag, category, or custom taxonomy instead.
-
AuthorPosts
