Comments (5)
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.
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.
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.
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.
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)
- Composer install problem HOT 3
- Using events on form collections including index HOT 3
- Setup httplug. HOT 1
- No more Stylesheet on Map ? HOT 2
- Yaml and/or XML config file for custom mapstyles HOT 3
- Show entire world, without wrapping
- Question: dependencies on ivory-serializer & httplug
- [Question] Google Roads API HOT 1
- Symfony 3.4 compatibility HOT 1
- Unable to find template "IvoryGoogleMapBundle:Form:place_autocomplete_widget.html.twig" HOT 2
- small error in documentation
- API Key missing on v3 version HOT 1
- Symfony 4 ready ? HOT 4
- Placeholder translation in PlaceAutocompleteType
- Google Map ApI Key Error
- egeloen IvoryGoogleMapBundle ApI Key Error
- [RFC] Will this bundle still be maintained as of 2019 ?
- rawgit is ending - 404 infobox_packed.js
- Maps do not display HOT 2
- NEW MAINTAINED FORK
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ivorygooglemapbundle.