Set Location value on Map Field Type

This topic is: not resolved


Viewing 3 posts - 1 through 3 (of 3 total)
Author Posts
March 29, 2014 at 3:42 am #3457
h2 Media Labs
Post count: 4

I would like to have the map field type default to the address contained in the post.

I don’t see the mpft map listed on the field types reference in the docs, so I can’t directly access its properties.

Thanks, Mary

March 31, 2014 at 10:01 pm #3459
Post count: 207

Hey Mary,

Sorry, I don’t quite understand the specifics. Are you trying to get the map to display in your template?

If that’s what you’re trying to do, the best way to do this involves 2 steps. First, add helper code for the map, to output the scripts necessary to embed the map, as shown in this gist:

Next, supposing you had a field set called details, and a field named location, add the following code into your theme:

That will output a div with the class “mp-map” and a script which will embed the map at the selected location. This div is classed with “mp-map” which can be styled with CSS to allow you to tweak the width and height etc.

Does that help? Let me know if I’ve misunderstood the question.

Sorry about the gap in the documentation for this. The map class is now listed in the class reference, but there is still not enough info on how to embed. I’ll get onto that.



April 1, 2014 at 8:31 am #3460
h2 Media Labs
Post count: 4

I was trying to set the location field with an address that was already in the post, but figured out I can do that in the code, and leave the map in the post for those times when the address is not correct one for the map.

Thanks for your help 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Latest From the Blog

MasterPress 1.4.1 is now available

27th May 2024

This update addresses backwards compatibility issues that were introduced in the previous update. There were some edge cases where PHP 7 had issues and it didn’t work at all on PHP 5.6. We have now changed it so that the PHP 8 compatibility changes will now only affect PHP 8 and will be more thorough… 

Plugin Requirements

MasterPress requires a minimum of WordPress version 4.9, MySQL 5.6, and PHP version 5.6.20.

We also recommend that PHP is configured to use a memory limit of 64MB per request (128MB may be required for sites with higher complexity).

This plug-in is not compatible with the hosted service.

Three AM