Coder Social home page Coder Social logo

Unclear Doc about ivorygooglemapbundle HOT 5 CLOSED

egeloen avatar egeloen commented on July 17, 2024
Unclear Doc

from ivorygooglemapbundle.

Comments (5)

egeloen avatar egeloen commented on July 17, 2024

I know the documentation is very unclear, I need to rewrite it but I don't have lot of time actually...

Can you be more precise on what don't you understand because if I need to explain all the possibility of the Map ORM, it will be a very large post like you can see in documentation.

from ivorygooglemapbundle.

mablae avatar mablae commented on July 17, 2024

To be more precise: What steps are needed to implement the correct usage of "the ID & the association"? Let's say I want to persist your pre-build models with all details.

Thanks for your quick reply ;-)

from ivorygooglemapbundle.

mablae avatar mablae commented on July 17, 2024

Maybe I can do a little bit of rewriting the docs tomorrow, I want to work with your bundle, I'll do a fork so you can easily merge my pull requests when wanted....

from ivorygooglemapbundle.

egeloen avatar egeloen commented on July 17, 2024

The pre-build model are located in Resources/public/config/doctrine. It's super classes ORM mapping.

I will give you a simple example where a map is linked to markers. Of course, a map can have rectangles, polylines & others. The steps are the same for this entities.

First, you need to create a map, a marker, a coordinate & a bound class in your bundle which extends the coreesponding classes in Ivory\GoogleMapBundle\Entity\*. Warning, your entities need to be located in your Entity folder.
Secondly, in their classes, you need to create an ID with this getter.
Thridly, like you can see in Ivory\GoogleMapBundle\Model\Map, a map can have a collection of markers. So if you want to persist the markers with a map, you need to initialize an ArrayCollection in the map constructor for their markers.

Map class:

use Ivory\GoogleMapBundle\Entity\Map as BaseMap;
use Doctrine\Common\Collections\ArrayCollection;

class Map extends BaseMap
{
    protected $id;

    public function __construct()
    {
        // Call the parent constructor
        parent::__construct();

        // Link map to a center entity and/or a bound entity
        $this->center = new Coordinate();
        $this->bound = new Bound();

        // Initialize the array collection
        $this->markers = new ArrayCollection();
    }

    public function getId()
    {
        return $this->id;
    }
}

Marker class:

use Ivory\GoogleMapBundle\Entity\Marker as BaseMarker;

class Marker extends BaseMarker
{
    protected $id;

    public function __construct()
    {
        // Call parent constructor
        parent::__construct();

        // Link marker to a position entity
        $this->position = new Coordinate();
    }

    public function getId()
    {
        return $this->id;
    }
}

After creating your classes, you need to define your ORM mapping

Map ORM mapping:

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <entity name="Namespace\Entity\Map">
        <id name="id" type="integer">
            <generator strategy="AUTO" />
        </id>
        <one-to-one field="center" target-entity="Namespace\Entity\Coordinate" />
        <one-to-one field="bound" target-entity="Namespace\Entity\Bound" />
        <many-to-many field="markers" target-entity="Namespace\Entity\Marker" />
    </entity>

</doctrine-mapping>

Marker ORM mapping:

// src/YourBundle/Resources/config/doctrine/Marker.orm.xml
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <entity name="Namespace\Entity\Marker">
        <id name="id" type="integer">
            <generator strategy="AUTO" />
        </id>
        <one-to-one field="position" target-entity="Namespace\Entity\Coordinate" />
    </entity>

</doctrine-mapping>

from ivorygooglemapbundle.

mablae avatar mablae commented on July 17, 2024

Thanks again! Thats what I needed. I'm very new to symfony2, so I'm not that good at it yet.

from ivorygooglemapbundle.

Related Issues (20)

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.