Querying latitude and longitude into google maps correctly
Querying latitude and longitude into google maps correctly
Querying latitude and longitude into google maps correctly
Add different custom markers for different post types in Google maps API
Meta seems like a fine place for storing this data. To make it more compact: $markers = array( ‘carrot’ => ‘marker_url_1’, ‘beet’ => ‘marker_url_2’, ); $icon = isset( $markers[ $veggie_type ] ) ? $markers[ $veggie_type ] : $markers[0]; Or if you are sure you have markers for each type and you can rename the marker … Read more
Your 2nd foreach loop is a bug. $slug is a string with a single value, and you cannot pass a string to a foreach loop. If you set debug to true, you will see an error message telling you just this. You can simply just do //Different markers for different types $car_type = get_the_terms( $post->ID, … Read more
First of all enqueue the Google Maps API js in the right way. look for a function which is hooked on wp_enqueue_scripts and wp_enqueue_script() to enqueue Google Maps API function wp_mk_scripts() { if ( is_singular() ) { wp_enqueue_script( ‘wp-mk-maps-js’, ‘https://maps.googleapis.com/maps/api/js’, array( ‘jquery’ ), null, true ); wp_enqueue_script( ‘wp-mk-gmaps-function’, get_stylesheet_directory_uri() . ‘/js/maps.js’, array( ‘jquery’ ), null, … Read more
Dealing with multiple Google maps API calls
Figured it out!!!!! Since we get the SQL query result with the help of “$wpdb” object we can access each row’s attribute as an associative array. As a result there isn’t a need for “mysql_fetch_assoc()” and “mysql_query()” functions. Also we need to define “$wpdb” object, so we require “wp-config.php” file.
The GPS position is saved on two post meta fields: geo_latitude and geo_longitude. You can use these meta values to draw the posts as markers on a Google Maps. For example, using Google Maps API, you could have a template like this: <h1>Posts on map</h1> <div id=”map” style=”height: 400px;”></div> <script> // init map with the … Read more
Try this code: <div class=”map”> <?php global $post; $location = get_field(‘location’, $post->ID); ?> <div class=”acf-map”> <div class=”marker” data-lat=”<?php echo $location[‘lat’]; ?>” data-lng=”<?php echo $location[‘lng’]; ?>”></div> </div> </div> Sometimes in the template you’re loading this you don’t have the post that the field belongs to, so you can try to fetch it in the global $post … Read more
In the main menu on the left, I went to Avada->Theme Options. On that page there was an option for Contact Form (that is used in the Contact page). Under Contact Form there is a “Google Map” option.