12

For anyone looking for this answer in the future, I took woony's code the extra mile and got everything working within Wordpress' post_meta table structure. This assumes you have two separate custom fields, one for Latitude (city_latitude) and one for longitude (city_longitude). Just pass the latitude, longitude, and distance parameters into a WP function ...


11

Can do this without any plugin, you need only the Google Maps API. Please note that if you plan to have 20 markers or more on a single page, you have to geolocate posts using coordinates and not addresses. To save coordinates from an address you can: manually use a service (something like this) call Google maps geocoding from WP admin when you create or ...


7

EDIT : use wp_enqueue_script as you want (enqueue in header or footer after jQuery as you want) to enqueue file called something like : gmap.js included in your plugin wp_enqueue_script('custom-gmap', plugin_dir_url( __FILE__ ).'inc/js/gmap.js', array('jquery'), false, true);//just change your path and name of file write this in your Js file :) $(...


4

Don't stress about it. There are many ways in which plugins and themes can break each other and you just can not avoid it when everything happens in the same execution space/context. You should test against whatever plugins and themes you want to make sure your code works with but there is just no way to make everybody at every point in time happy. Actually ...


4

I was able to get this working after a bit of fiddling. Give the #map-canvas element a height (you can do this in CSS): <div id="map-canvas" style="height:500px"></div> Add the callback argument to the google-maps script URL and add the defer and async attributes to the google-maps script tag. Also make custom-scripts a dependency for google-...


3

You are using iframe in tab structure.So, 1) When page loads fully, the iframe in itenary tab has display none. so it is not loading the zoomed map properly. 2) When you switch to itenary tab before loading completes, iframe is display block i.e visible so it loads the url/map properly. So for this what you can do is give id to your iframe say "#...


3

Lots of ways to proceed here. Here's one way to do it: Find a JavaScript/jQuery plugin that works with map markers. I used Mosne Map, it's old but it works. Generate the HTML markup that the above plugin will use. I needed a more user-friendly way to add markers, so I utilized ACF's Repeater Field type for this because I had one page with a map, so it was ...


2

To connect your meta fields with the "Geo Data Store"-Plugin, you simply take the name of the meta key/field and map it with the filter to the plugin. add_filter( 'sc_geodatastore_meta_keys', 'wpse82502_lat_lng_metakey_mapping' ); function wpse82502_lat_lng_metakey_mapping( $keys ) { $keys[] = "your_meta_key_field_name"; return $keys; } To get the ...


2

Enqueue your script and use wp_localize_script to pass data. function wpd_scripts() { wp_enqueue_script( 'wpd_script', get_stylesheet_directory_uri() . '/js/script.js', null, null, false ); wp_localize_script( 'wpd_script', 'WPD', array( 'stylesheet_dir' => ...


2

This part of the Google Maps script URL is the culprit: &callback=initMap It means that when the script is loaded it will attempt to run the initMap() function, but you're enqueueing your script that contains the function in the footer, after the Google Maps <script> tag, which you're outputting in the middle of the page. This means that your ...


1

I'm not sure whether you are using a plugin, or you are coding it yourself. Either way, you can use server side or client side to decode or encode your content. PHP offers the utf8_decode(); and utf8_encode(); functions, that can be used to decode or encode your content before sending it to the browser, or after being received by the server. If you need to ...


1

Rather than uploading the static files, the "WordPress way" would be to: Create a child theme Create a Page Template - this is where you can include your HTML for the map. You will probably also want to include basic theme tags such as wp_head() and wp_footer() so your header and footer are included and the page looks like the rest of your WordPress site. I ...


1

Google API's now requires API key for new domains, you should create an API key as per instructions here: https://developers.google.com/maps/documentation/javascript/get-api-key and edit the line in the plugin that loads the Google Maps API to include your key as the value of a 'key' parameter. Wherever you find one of these: "https://maps.googleapis.com/...


1

Google is now requiring a API key for the maps. Getting Started With Google Maps APIs


1

Use the JSON REST API - http://v2.wp-api.org - It lives as a plugin now but will eventually be part of WP Core - https://wordpress.org/plugins/rest-api/ To manually output JSON, use a combination of wp-ajax to handle requests and wp_json_encode() / wp_send_json_success for simple PHP Objects and Arrays. See https://codex.wordpress.org/AJAX_in_Plugins


1

The JS in the fiddle should be saved to a file, for example, scripts.js. If this was in a folder in the theme root called js you could enqueue the scripts like so: function add_wp_scripts() { wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js', array(), null, null ); ...


1

$prop_mapaddress contains your textfield value: <?php if(isset($prop_mapaddress)) { global $post; global $wpdb; $fromat_address = trim($prop_mapaddress); $fromat_address = str_replace(" ","+",$fromat_address); $address_obj = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=".$...


1

Use wp_localize_script: wp_enqueue_script('YOUR_SCRIPT_HANDLE'); $object = array( 'zoom' => get_option('map_zoom'), 'longitude' => get_option('map_longitude'), 'latitude' => get_option('map_latitude'), ); wp_localize_script('YOUR_SCRIPT_HANDLE', 'JSObject', $object); And then use it in your JS file like JSObject.zoom and the like.


1

I sugges you use wp_localize_script: http://codex.wordpress.org/Function_Reference/wp_localize_script to include arbitrary js data in your page


1

The best plugin I've found so far for this is Mappress...there is a pro version, which you might need. I've got it implemented here in the way you describe.


1

You can use the WP REST API plugin to add/manipulate/present media of a WordPress install from within your app. The page creation part I am not sure of, perhaps it'll need to be done manually - or you can create pages via the /pages/ endpoint. I'll let someone correct me if I'm wrong, but the API endpoints (which are available at the link as a plugin) ...


1

Is this what you are asking for? Use it after the code you posted to create posts in loop and use thier ids to update meta fields. Replace "post_type" with your custom post type. foreach ($markers as $marker){ $post_id = wp_insert_post(array( "post_title" => "something", "post_type" => "your-type", "post_status" => "...


1

Step one: Familiarize yourself with Google Maps Embed API; and sign up for API key: The iframe embed option, unlike the Javascript API, does not have usage limits but does not have as many options/features. Determine which MODE you require and observe the required url format and parameters. Step two: Collect address from user. For the sake of this ...


1

I had to add #map-canvas { height:100%!; } to my stylesheet.


1

You should try to replace the following jQuery part: action: 'process_shortcode_on_tab_click' with this one: action: 'process_shortcode_on_tab_click_action' to match your wp_ajax_process_shortcode_on_tab_click_action and wp_ajax_nopriv_process_shortcode_on_tab_click_action actions. Check for example the Codex on how to name the custom wp_ajax_$...


1

The default search is handled by WP_Query mostly by a method called parse_search(), which is triggered by the s parameter. You can search the source of WP_Query for is_search and piece together a few other bits and pieces. Or you can just create a query... $s = new WP_Query(array('s' => 'test')); ... dump the SQL... var_dump($s->request); ... and ...


1

I've done something similar for a client. I found it easiest to create my custom post types as part of a plugin and network activate it. Without reinventing the wheel, I used a plugin from WPMU Dev to show those posts on the main site. If creating the custom post type isn't your forte, WPMU Dev has a plugin that will help you with creating them. WPMU Dev ...


1

So I figured out the issue. I wasn't familiar enough with how urls are handled in XMLHttpRequest. I needed to change downloadUrl("http://wp-content/themes/oxygen-child/phpsqlajax_genxml3.php", function(data) { to downloadUrl("http://www.theworldsflgiht.com/wp-content/themes/oxygen-child/phpsqlajax_genxml3.php", function(data) { Thanks for the help ...


1

Sorry for reviving this post, but it was on the front page and I noticed that it's very old too late... Here's my take on this problem: // This will filter the shortcode attributes and will insert custom // value for the "cat" parameter function filter_gmaps_shortcode_atts( $atts ) { // We add a custom value in the $cat parameter if ( is_tax( '...


1

You have quite a bit of markup for that shortcode. Trying to pass all of that as a shortcode is going to be trouble. I pulled it apart to look at it. id="map" z="11" w="100%" h="300" scrollwheel="false" maptype="ROADMAP" address="Southampton, United Kingdom" marker="true" markerimage="http://anachronistic.local:9102/wp-content/plugins/_TomRush/inc/js/...


Only top voted, non community-wiki answers of a minimum length are eligible