Closed seanhawkridge closed 11 years ago
Hi Sean, need a few more details here. I created a new post, left the map field set to "no", and I've got this filter on the_content
:
add_filter( 'the_content', 'test_output' );
function test_output() {
return slt_cf_gmap( 'output', 'gmap', 'stored_data', 500, 500, true, 'roadmap', false );
}
Nothing is output.
I set the radio to "yes" and left the map at its default (for me, it centres around Northampton). Saved post, viewed, map is there. Edited again, set back to "no", map disappears.
Nothing unexpected really. Please have a closer look at your code & check the meta field values in phpMyAdmin, and let me know if you find the issue or find a way to replicate it.
I think I'm getting confused about how the map function works. I have the custom field set up as normal in my functions.php:
slt_cf_register_box( array(
'type' => 'post',
'title' => 'Map',
'id' => 'locationmap',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'map',
'label' => 'Map',
'type' => 'gmap',
'width' => '380',
'height' => '240',
'description' => 'Add a map to the sidebar here...',
'scope' => array( 'event', 'news', 'post', 'page', 'person', 'except_posts' => array( 4 ) ),
'capabilities' => array( 'edit_posts' )
),
)
));
and in my template I'm just echoing stl_cf_gmap()
- I had thought that was enough. But it's echoing a map even if I haven't set one for a particular page. And if I add any settings at all to the function in my template it doesn't display the map. Where am I going wrong? I've tried the example you described above, and it's not displaying anything even for posts where I have a location set...
Check the docs for the function:
http://sltaylor.co.uk/wordpress/plugins/slt-custom-fields/docs/#functions-gmaps
Note the defaults. $name
defaults to 'gmap'
, and your field has the name 'map'
- maybe that's the issue? If it is, do you think the docs aren't clear that these need to match?
If it isn't, I can't replicate the issue (clean install of the latest 3.5 release candidate).
Weird-
I've checked the name - I've changed it to location
and in my template I have:
<div class="map">
slt_cf_gmap('output', 'location', 'stored_data', 380, 240, true, 'roadmap', true, '', false );
</div>
Which works fine for pages where a map is set - but when a map isn't set, it's still outputting - if I check my source I can see
<div class="map">
<div id="_slt_location_map_container" class="gmap_output" style="width:380px;height:240px;"></div>
</div><!-- .map -->
with
<script type="text/javascript">
jQuery( document ).ready( function($) {
slt_cf_gmap_init( '_slt_location_map_container', 'output', true, '55.877704802038835,-4.523828125000029', '55.877704802038835,-4.523828125000029', 5, 'roadmap' );
});
</script>
And nothing at all in the database...
Any ideas? It's driving me crazy!
I've tried to replicate your situation above, and can't. When the map isn't set on the post in question, no markup or JS gets output.
I can't say it's not some issue that needs addressing in the plugin, but since I can't replicate it on a clean WP install, you'll have to hunt this one down I'm afraid! Keep me posted.
New posts with a google map field are displaying a map with the pointer on Glasgow(!), when the radio button is set to 'no'.
If I add a location, save the page and remove the location again, the map disappears.