title: WordPress ACF Google Maps Radius Search
body: <p>i got a big Problem and have no Solution.
  i work with <strong>WordPress</strong> and <strong>Custom-Post-Type (CPT)</strong> and <strong>Advanced Custom Fields (ACF)</strong>.
  I create a new CPT called &quot;projekt&quot; and a <strong>ACF &quot;Google Map Field&quot;</strong> which saves the <strong>Adress, longtitude and latitude</strong>. The bad thing is ACF Fields were saved <strong>serialzed</strong> in the MySQL DB.</p>
  <p><strong>i found the following SQL-Query on the Net to calculate the Radius.</strong></p>
  <pre><code>$lat = '50.12335';
  $lng = '-1.344453';
  $radius = 10; // (km)  
  
  ???....WHERE ( 6371 * acos( cos( radians(&quot; . $lat . &quot;) ) 
  * cos( radians( lat ) ) 
  * cos( radians( lng ) 
  - radians(&quot; . $lng . &quot;) ) 
  + sin( radians(&quot; . $lat . &quot;) ) 
  * sin( radians( lat ) ) ) ) &lt;= &quot; . $radius . &quot;)&quot;
  </code></pre>
  <p>i don't know how to build the query, because the query needs to get the longtitude and latitude info from the serialized ACF fields.</p>
  <p><strong>DB-Field &quot;meta_value&quot;:</strong></p>
  <pre><code>a:13:{s:7:&quot;address&quot;;s:44:&quot;Moskauer Straße 5, Düsseldorf, Deutschland&quot;;s:3:&quot;lat&quot;;d:51.2199565;s:3:&quot;lng&quot;;d:6.8044928;s:4:&quot;zoom&quot;;i:14;s:8:&quot;place_id&quot;;s:114:&quot;EiNNb3NrYXVlciBTdHIuLCBEw7xzc2VsZG9yZiwgR2VybWFueSIuKiwKFAoSCZV-jR3Ny7hHEVVgUQUBF7q8EhQKEgkBGQXwtsu4RxHgwS1K_GAnBQ&quot;;s:4:&quot;name&quot;;s:16:&quot;Moskauer Straße&quot;;s:11:&quot;street_name&quot;;s:16:&quot;Moskauer Straße&quot;;s:17:&quot;street_name_short&quot;;s:13:&quot;Moskauer Str.&quot;;s:4:&quot;city&quot;;s:11:&quot;Düsseldorf&quot;;s:5:&quot;state&quot;;s:19:&quot;Nordrhein-Westfalen&quot;;s:11:&quot;state_short&quot;;s:3:&quot;NRW&quot;;s:7:&quot;country&quot;;s:11:&quot;Deutschland&quot;;s:13:&quot;country_short&quot;;s:2:&quot;DE&quot;;}
  </code></pre>
  <p><strong>i can get all my &quot;projekt&quot;'s with:</strong></p>
  <p>maybe it's possible to extend the following query</p>
  <pre><code>SELECT P.ID, P.post_title, P.post_content, P.post_author, meta_value
  FROM wp_posts AS P
  LEFT JOIN wp_postmeta AS PM on PM.post_id = P.ID
  WHERE P.post_type = 'projekt' and P.post_status = 'publish' and ( meta_key = 'adress' )
  ORDER BY P.post_date DESC
  </code></pre>
  <p><strong>result is:</strong></p>
  <pre><code>ID|post_title  |post_content|post_author|meta_value
  55|Test Projekt|            |1          |a:13:{s:7:&quot;address&quot;;s:44:&quot;Moskauer Straße 5, Düss...
  </code></pre>
  <p>Do you got any Solution for me ?</p>
  <p>Thank You!</p>