Coder Social home page Coder Social logo

vichgeographicalbundle's Introduction

VichGeographicalBundle

The VichGeographicalBundle provides automatic geographic coordinate querying for ORM entities and ODM documents. The bundle also provides functionality for rendering of JavaScript maps for these entities in your Symfony2 project using annotations. It also allows for object oriented JavaScript maps to be rendered without using any of the coordinate querying features. The bundle uses Google maps by default, but other maps are always being integrated and you can always write your own map renderer.

Documentation

For usage documentation, see:

Resources/doc/index.md

For license, see:

Resources/meta/LICENSE

vichgeographicalbundle's People

Contributors

dlugs avatar dustin10 avatar eichie avatar mdpatrick avatar nelrann avatar robocoder avatar snc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vichgeographicalbundle's Issues

Disable lookup?

Is there any recommended way to disable lookup based on any sort of criteria? For example, when running unit tests I don't want the Google map lookup to fire (since it fails sometimes and I dont' want that to break testing), but there doesn't appear to be any way to make lookup conditional other than annotation in the Entity itself which can't be written to check something like SYMFONY_ENV.

Right now when I run tests, the Mock Data import is causing it to lookup as they're inserted which is causing test problems.

neither latitude nor longitude filled on persist.

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?

Only Latitude / Longitude from entity.

Hi,

Is it possible to generate dynamic map with only Latitude / Longitude from entity and no function getAddress() ?

I get Latitude and Longitude from GPS and not from an address but it seems mandatory to have a Vich\GeographicalQuery().

Thanks in advance,

Updating entities

Is it possible that entity is updated just if longitude/latitude is null or something? Because sometimes google api return no result for longitude/latitude and then i have to correct it manually.. and after update it goes to 0, 0 ...

Maybe it would be good to implement * @vich\Geographical(on="update_if_null") or soemthing ...?

infoWindow does not show up

I did everything to make infoWindow show up but failed. I have set $this->setShowInfoWindowsForMarkers(true); but both true and false do nothing. Does anyone has any idea what might be the fault ?

"Unable to find Geographical annotation"

as i already lined out on IRC, there is some problem with loading the annotation from the class. weird thing is: the venue entity long and lat coordinates get inserted correctly, but rendering the map throws this error.
this error occures at MapHelper.php at line 162:

        $annot = $this->driver->getGeographicalAnnotation($obj);
        if (null === $annot) {
            throw new \InvalidArgumentException('Unable to find Geographical annotation');
        }

as I believe this is related to some reflection or proxy issue...

Clustering

Does VichGeographicalBundle support marker clustering?

Unable to find GeograhicalQuery annotation

Hi, i have this error and in other issue was resolved, but not for me!

Stack Trace

    in /home/iraqexcavations/iraq_bootstrap/vendor/vich/geographical-bundle/Vich/GeographicalBundle/EventListener/GeographicalListener.php at line 110  -+
                }

                if (null === $geoQuery) {
                    throw new \InvalidArgumentException('Unable to find GeograhicalQuery annotation.');
                }

                $queryMethod = $geoQuery->getMethod();
    at GeographicalListener ->updateObject (object(City), object(Geographical), null)
    in /home/iraqexcavations/iraq_bootstrap/vendor/vich/geographical-bundle/Vich/GeographicalBundle/EventListener/GeographicalListener.php at line 73  -+
    at GeographicalListener ->prePersist (object(LifecycleEventArgs))
    in /home/iraqexcavations/iraq_bootstrap/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php at line 61  -+
    at ContainerAwareEventManager ->dispatchEvent ('prePersist', object(LifecycleEventArgs))
    in /home/iraqexcavations/iraq_bootstrap/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php at line 808  -+
    at UnitOfWork ->persistNew (object(ClassMetadata), object(City))
    in /home/iraqexcavations/iraq_bootstrap/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php at line 1588  -+
    at UnitOfWork ->doPersist (object(City), array('000000007ac0bf8f00000000205d1d73' => object(City)))
    in /home/iraqexcavations/iraq_bootstrap/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php at line 1546  -+
    at UnitOfWork ->persist (object(City))
    in /home/iraqexcavations/iraq_bootstrap/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php at line 565  

thanks in advance
and great job yours ๐Ÿ‘
stefano

Add a dependency to geocoderBundle

Hi,

I would like to know if you would be interested by an integration of https://github.com/willdurand/BazingaGeocoderBundle on this bundle. QueryService at this moment supports only Google. Since Geocoder is the reference in php for geolocate an address, ip, etc ... i guess it would be a good solution.

At this moment, when rate limit of google is exceeded, there is no way to fallback to an other one provider.

Would you be interested by an improvement like this ? I can contribute.

Multiple maps

This bundle is absolutely amazing!

Is there a way to plot multiple maps instead of plotting all the markers on one map. Is this already possible?

The only way I can think of is having

{% for location in locations %}

{{ vichgeo_map_for('location', location) }}

{% endfor %}

The thing is that in LocationMap, we have:

$this->setContainerId('map_canvas');

Should I override MapHelper::prepareAndRender()?

I was just wondering if there is a way to dynamically render a map for each iteration in the loop.

Many thanks for sharing this stunning bundle.

Elegant Proxy detection

Right now the AnnotationDriver checks if the class name contains the Proxies\ string. This not the most elegant solution as this may not be the configured namespace (it is by default). This should be refactored to use a service that checks based on the db_driver configured as the Proxy base class is dependent on this.

Unit Tests

More unit tests need to be added to cover all functionality.

"Unable to find GeograhicalQuery annotation."

I just add the bundle to my project and I have the following class :

use Vich\GeographicalBundle\Annotation as Vich;

/**
*

  • @Orm\Entity()

  • @vich\Geographical(on="update")
    */
    class Contact
    {

    /**Some variables */

    /**

    • @Orm\Column(type="decimal", scale="7")
      */
      protected $latitude;

    /**

    • @Orm\Column(type="decimal", scale="7")
      */
      protected $longitude;

    /**

    • @vich\GeographicalQuery
      *
      /
      public function getAdress()
      {
      return sprintf(
      '%s, %s, %s %s',
      $this->rue,
      $this->ville,
      $this->pays,
      $this->cp
      );
      }
      /
      *Some methods */
      }

No special configuration.

When the object is updated I have the following error :

"Unable to find GeograhicalQuery annotation. "

Im not sure if I forgot something or if it's a problem with the bundle.

Thanks a lot for your work !

hello dustin10

i use your bundle to render a google mpas with entities..
and i would like if you add the way to use a custom marker icon and a marker shadow

best regrads

google not defined

Whether I use jquery_google or the google renderer I get "google is not defined" or "$ is not defined". Any thoughts on why this would happen? What am I doing wrong? Thank you.

Custom Icons For Annotated Entities

I have not figured out a good way to use custom icons with annotated entities. It is simple in pre-configured maps because the user is creating the MapMarker objects himself, but when adding markers for annotated entities it is not so simple because the decision on what icon to use will probably be a runtime decision.

DoctrineODM support?

Hi,

without delving too much into the code, I noticed you're using the DBAL to query entities. Do you think it could work with DoctrineODM (MongoDB) as well?

Thx

Las

Malformed composer.json file

Require in composer.json has unnecessary comma after php version, which prevents adding your bundle to packagist.
"require": {
"php": ">=5.3.2",
},

Should be:
"require": {
"php": ">=5.3.2"
},

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.