Search code examples
phpparse-platform

Is it possible to get Lat and Lon from GeoPoint from parseplaform using php


I wanna get lat and lon from GeoPoint, i've been trying many ways like this

$cordquery = new ParseQuery("Object");
    $cordquery->equalTo("cityCode", 1);
    $xd = $cordquery->find();
    
    foreach($xd as $g){
    $geopoint = $g->get('location');
    //$lat=$geopoint->get('latitude');
    echo $geopoint['Object']['latitude'];
}

But i cannot use object of type Parse\ParseGeoPoint as array. In docs i hadnt found any solution.


Solution

  • Ok i resolved this problem by geting location first, then i used function getLatitude.

        $cordquery = new ParseQuery("Object");
        $cordquery->equalTo("cityCode", 1);
        $xd = $cordquery->find();
        
        foreach($xd as $g){
        $geopoint = $g->get('location');
        $lat=$geopoint->getLatitude();
        echo $lat;
    }