[Plugin Advanced Custom Fields] Display Google map on your theme
-
Hi there,
maybe this code is help you for display a Google map from field google map in Advanced Custom Fields plugin.
Peut être ce bout de code pourra vous être utile pour afficher dans votre thème, la carte google généré via le champs “Google map” du plugin Advanced Custom Fields
Working whith WordPress 3.8.1
<div id="view1"> <?php $location = get_field('carte_google'); if( ! empty($location) ): ?> <div id="map" style="width: 100%; height: 350px;"></div> <script src='https://maps.googleapis.com/maps/api/js?sensor=false' type='text/javascript'></script> <script type="text/javascript"> //<![CDATA[ function load() { var lat = <?php echo $location['lat']; ?>; var lng = <?php echo $location['lng']; ?>; // coordinates to latLng var latlng = new google.maps.LatLng(lat, lng); // map Options var myOptions = { zoom: 9, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; //draw a map var map = new google.maps.Map(document.getElementById("map"), myOptions); var marker = new google.maps.Marker({ position: map.getCenter(), map: map }); } // call the function load(); //]]> </script> <?php endif; ?> </div>
- The topic ‘[Plugin Advanced Custom Fields] Display Google map on your theme’ is closed to new replies.