Tag Info

Hot answers tagged

9

I would modify the answer from gabrielk and the linked blog post by using database indexes and minimizing the number of actual distance calculations. If you know the coordinates of the user and you know the maximum distance (say 10km), you can draw a bounding box that is 20km by 20km with the current location in the middle. Get these bounding coordinates ...


7

First you need a table that looks something like this: zip_code lat lon 10001 40.77 73.98 ...populated for each zip code. You can expand on this by adding city and state fields if you want to look up that way. Then each store can be given a zip code, and when you need to calculate distance you can join the lat/long table to the store ...


6

This might be too late for you, but I'm going to reply anyway, with a similar answer as I gave to this related question, so future visitors can refer to both questions. I would not store these values in the post metadata table, or at least not only there. You want a table with post_id, lat, lon columns, so you can place an index of lat, lon and query on ...


4

What precision do you need? if it's a state/national wide search maybe you could do a lat-lon to zip lookup and have precomputed distance from zip area to zip area of the restaurant. If you need accurate distances that won't be a good option. You should look into a Geohash solution, in the Wikipedia article there is a link to a PHP library to encode decode ...


4

There's Geo Data Store by our own man, @Brady. It does a perfect job in one of my installations. It uses a custom table, that stores only ID, meta ID, lat and lng information, so your queries stay quick and brief, even when your database starts scaling. It got a 5 star rating from my side. This plugin is meant to be used by other developers and to be ...


3

The MySQL documentation also includes information on spatial extensions. Oddly, the standard distance() function isn't available, but check this page: http://dev.mysql.com/tech-resources/articles/4.1/gis-with-mysql.html for details on how to "convert the two POINT values to a LINESTRING and then compute the length of that." Note that every vendor is likely ...


3

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 ...


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

Seems like you are looking for a pure SQL solutions for this. You can achieve this by running the following query: UPDATE wp_posts SET latitude_longitude = CONCAT(latitude, ", " , longitude); That will work for you, just double check the name of the columns: latitude_longitude, latitude and longitude. Update If you want to run that SQL query each ...


2

You could use this plugin, although it may only be compatible to 3.2.1. And this plugin may help you out, although it seems a little complicated to implement a map for all the posts. You could also use a custom field for lat/long on each post, and then create markers using wpdb calls, grabbing the post_meta data, and using the Google Maps API to place the ...


2

I would say use a $_SESSION['var'] var or $_COOKIE[] to check if the link is clicked. Looks like the plugin is calling the geo_redirect_client_location function and then redirecting. function geo_redirect_client_location(){ $geo = new Geo_Redirect(); $geo->checkIfRedirectNeeded(); } I'm not familiar enough with the plugin but I would so ...


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 ...


1

Search Help Google to determine the site language and to serve the right page for the users in different countries. Mark up language attributes correctly. Use <html lang="en_UK"> and <html lang="en_US">. Use <link rel="alternate" hreflang="x" /> in page <head>. It's also important to specify site targeting in Google Webmaster Tools. ...


1

Try wrapping your array in json_encode(): function add_map_data() { $objName = "MapData"; $array = array( "MapViewLatitude" => "51.505", "MapViewLongitude" => "-0.09", ); wp_enqueue_script( 'mapdata', get_bloginfo('template_url').'/custom/map.js', null, null, false ); ...


1

See which of the following works best for you: http://wordpress.org/extend/plugins/wp-google-maps/ http://wordpress.org/extend/plugins/geo-location-comments/ http://wordpress.org/extend/plugins/google-latitude-history/


1

Can you use a plugin? I just released not long ago http://geomywp.com it basically does what you want. If you want to do it yourself so this is how I did it: The plugin adds address custom fields (as meta boxes) to your post type. When post is being saved the address being converted to lat/long using google API and the data being saved in a custom table. ...


1

If memory serves, Bad Behavior allows to configure a few aspects of geo-blocking. There might be a few wp.org plugins tagged as security that allow to implement geo-blocking too. That said, I don't think it's the right approach. The best is to hop over to askapache.com. There's tons of security-related, htaccess-based stuff over there. Geo-blocking is among ...


1

I'm not entirely sure if this will help in EXACTLY the way you are looking for, but when it comes to map integration into posts, I love to use MapPress. It supports a pretty robust API which allows you to hook into the plugin to do some custom things, and I'm sure with a little work you could get to where you want to be with your project. I don't usually ...


1

I would suggest rolling your own. Create a metabox that allows posts to store lats and longs on posts. Then create a page that finds all the posts with the tags that you want that can grab the lats and longs from each post meta data. Using that post meta data create a json variable in the html that includes all the lat long info for all the posts that ...


1

I would duplicate the coordinates of the posts in a separate table (post_id, lat, lon), with an index on (lat, lon). With all the joins and the casts I doubt the database can use an efficient index with your query. I once wrote an answer to a similar question using this approach.


1

First of all get_users_of_blog has been deprecated, so you should use get_users instead, or run a WP_User_Query. After that, the_author_meta echo the meta value, not return anything. To return the meta you should use get_the_author_meta() $blogusers = get_users( $args ); // for args see codex if ($blogusers) { foreach ( $blogusers as $bloguser ) { ...


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.



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