Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Google Store Locator

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 812 Views
  • Mgc
    Avatar
    Community Member
    23 Posts

    Google Store Locator Link to this post

    Trying to make this tutorial work on SS http://code.google.com/apis/maps/articles/phpsqlsearch.html

    Here is my current code;

    <code>function markers() {
          // Get parameters from URL
          $center_lat = $_GET["Lat"];
          $center_lng = $_GET["Lng"];
          $radius = $_GET["radius"];
          
          $Markers = DB::query("SELECT Address, Name, Lat, Lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( Lat ) ) * cos( radians( Lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( Lat ) ) ) ) AS distance FROM Marker HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
           mysql_real_escape_string($center_lat),
           mysql_real_escape_string($center_lng),
           mysql_real_escape_string($center_lat),
           mysql_real_escape_string($radius));
          
          //$Markers = DataObject::get('Marker');
          return $this
          ->customise(array("Markers" => $Markers))
          ->renderWith("MarkerXML");
          }
    </code>

    as you can see i have a function that generates a xml file with all the markers that have been set on the backend admin.

    The file works great when i do a DataObject:get on the Marker class.

    However, this only brings up all markers.

    what i want is for the markers to come up based on the lng and lang using the formula above.

    The current code gives this error:

    [Notice] Undefined index: Lat

    any help or direction on this would be really appreciated ... regards,

    Miguel

    812 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.