Hello,
Does anyone know how I can set satellite map display as default on the backend?
I don’t think this is possible in the plugin yet.
I would recommend that you hook into the Google map API and edit the Map Options object to turn on the Maptype control. This will be done through the following code:
mapTypeControl:true
You can learn more about this here: http://www.w3schools.com/googleapi/google_maps_controls.asp
For the the frontend view, please take a look at this blog: http://biostall.com/advanced-custom-fields-street-view-in-google-map/
Thank you for your Answer James.
Should it work if I changed the “../advanced-custom-fields-pro/fields/google-map.php” file on lines 38, 44 and 104? Being the following form:
Line 38
$this->defaults = array(
'height' => '',
'center_lat' => '',
'center_lng' => '',
'zoom' => '',
'mapTypeId' => 'satellite'
);
Line 44
$this->default_values = array(
'height' => '400',
'center_lat' => '-37.81411',
'center_lng' => '144.96328',
'zoom' => '14',
'mapTypeId' => 'satellite'
);
Line 104
$atts = array(
'id' => $field['id'],
'class' => "acf-google-map {$field['class']}",
'data-lat' => $field['center_lat'],
'data-lng' => $field['center_lng'],
'data-zoom' => $field['zoom'],
'mapTypeId' => 'satellite',
);
I think, instead of modifying the core files, you can use the following code instead:
add_action('acf/input/admin_footer', 'my_acf_change_map_to_satelite');
function my_acf_change_map_to_satelite() {
?>
<script type="text/javascript">
(function($) {
acf.add_filter('google_map_args', function( args, $field ){
// Change Map to Satellite
args['mapTypeId'] = 'satellite';
// return
return args;
});
})(jQuery);
</script>
<?php
}
This page should give you more idea about it: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/.
I hope this helps 🙂
The topic ‘Google Map Satellite’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.