Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neither latitude nor longitude filled on persist. #27

Open
oopsFrogs opened this issue Dec 20, 2012 · 0 comments
Open

neither latitude nor longitude filled on persist. #27

oopsFrogs opened this issue Dec 20, 2012 · 0 comments

Comments

@oopsFrogs
Copy link

I don't know this is a issue or not, but just can't find any answer about it, please help:

I used class table inheritance for my entity:

 // ACME\CommonBundle\Entity\Location.php

namespace ACME\CommonBundle\Entity;

use Doctrine\ORM\Mapping as ORM,
    Symfony\Component\Validator\Constraints as Assert,
    Vich\GeographicalBundle\Annotation as Vich;

/**
 * @ORM\Entity
 * @ORM\InheritanceType("JOINED")
  * @ORM\DiscriminatorColumn(name="discr", type="string")
  * @ORM\DiscriminatorMap({
  *         "branch" = "\ACME\BranchBundle\Entity\Branch", 
  *         "place"  = "Place"
  * })
  * 
  * @Vich\Geographical
  * 
  */
 class Location
 {
      ......

     /**
      * @ORM\Column(type="decimal", scale=7, nullable=true)
      * @var decimal
      */
     protected $latitude;

     /**
      * @ORM\Column(type="decimal", scale=7, nullable=true)
      * @var decimal
      */
     protected $longitude;

      ......

     /**
      * Set latitude
      *
      * @param decimal $latitude
      */
     public function setLatitude($latitude)
     {
         $this->latitude = $latitude;
     }

     /**
      * Set longitude
      *
      * @param decimal $longitude
      */
     public function setLongitude($longitude)
     {
         $this->longitude = $longitude;
     }

      /**
       * @Vich\GeographicalQuery
       */
      public function getFullAddress()
      {
          return sprintf(
              '%s, %s %s',
              $this->address,
               implode(', ', $this->geography->getFullGeographyHierarchyArray()),
              $this->zipCode
          );
     }
 }

//ACME\BranchBundle\Entity\Branch.php

namespace ACME\BranchBundle\Entity;

use ACME\CommonBundle\Entity\Location,
    ......

/**
 * ACME\BranchBundle\Entity\Branch
......
 */
class Branch extends Location
{
    ......
}

When I create and persist new Branch entity, the latitude and longitude all remained null, did I miss anything?

PS. I crawled around web and found than I needed some 'key' to use the Google Geocode API, but the documentation of this bundle didn't mention about it, was that what I missed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant