4242-----
4343
4444This bundle registers a ` bazinga_geocoder.geocoder ` service which is an instance
45- of ` Geocoder ` . You'll be able to do whatever you want with it.
45+ of ` Geocoder ` . You'll be able to do whatever you want with it but be sure to
46+ configure at least ** one provider** first.
4647
4748** NOTE:** When using ` Request::getClientIp() ` with Symfony 2.1+, ensure you have
4849a trusted proxy set in your ` config.yml ` :
@@ -67,14 +68,15 @@ information in your development environment, for instance:
6768 /**
6869 * @Template()
6970 */
70- public function indexAction()
71+ public function indexAction(Request $request )
7172 {
7273 // Retrieve information from the current user (by its IP address)
73- $result = $this->geocoder
74+ $result = $this->container
75+ ->get('bazinga_geocoder.geocoder')
7476 ->using('yahoo')
75- ->geocode($this->getRequest() ->server->get('REMOTE_ADDR'));
77+ ->geocode($request ->server->get('REMOTE_ADDR'));
7678
77- // Find the 5 nearest objects from the current user.
79+ // Find the 5 nearest objects (15km) from the current user.
7880 $objects = ObjectQuery::create()
7981 ->filterByDistanceFrom($result->getLatitude(), $result->getLongitude(), 15)
8082 ->limit(5)
@@ -129,12 +131,14 @@ Here is an example:
129131` ` ` php
130132<?php
131133
132- public function geocodeAction()
134+ public function geocodeAction(Request $request )
133135{
134- $result = $this->container->get('bazinga_geocoder.geocoder')
135- ->geocode($this->container->get('request')->server->get('REMOTE_ADDR'));
136+ $result = $this->container
137+ ->get('bazinga_geocoder.geocoder')
138+ ->geocode($request->server->get('REMOTE_ADDR'));
136139
137- $body = $this->container->get('bazinga_geocoder.dumper_manager')
140+ $body = $this->container
141+ ->get('bazinga_geocoder.dumper_manager')
138142 ->get('geojson')
139143 ->dump($result);
140144
@@ -196,60 +200,66 @@ Toolbar](https://raw.github.com/willdurand/BazingaGeocoderBundle/master/Resource
196200Reference Configuration
197201-----------------------
198202
199- You have to define the providers you want to use in your configuration.
200- Some of them need information (API key for instance).
203+ You MUST define the providers you want to use in your configuration. Some of
204+ them need information (API key for instance).
201205
202206You'll find the reference configuration below :
203207
204208` ` ` yaml
205209# app/config/config*.yml
206210
207211bazinga_geocoder:
208- fake_ip: 999.999.999.999
212+ fake_ip:
213+ enabled: true
214+ ip: ~
215+ priority: 0
209216 adapter:
210- class: \Y our \C ustomAdapter
217+ class: ~
211218 providers:
212219 bing_maps:
213- api_key: XXXXXXXXX
214- locale: xx_XX
215- google_maps:
216- locale: xx_XX
217- region: xx_XX
220+ api_key: ~ # Required
221+ locale: ~
222+ cache:
223+ adapter: ~ # Required
224+ provider: ~ # Required
225+ locale: ~
226+ lifetime: 86400
218227 ip_info_db:
219- api_key: XXXXXXXXX
228+ api_key: ~ # Required
220229 yahoo:
221- api_key: XXXXXXXXX
222- locale: xx_XX
230+ api_key: ~ # Required
231+ locale: ~
223232 cloudmade:
224- api_key: XXXXXXXXX
225- free_geo_ip: ~
233+ api_key: ~ # Required
234+ google_maps:
235+ locale: ~
236+ region: ~
237+ use_ssl: false
226238 openstreetmaps:
227- locale: xx_XX
228- host_ip: ~
229- geoip: ~
230- mapquest: ~
231- oiorest: ~
232- geocoder_ca: ~
233- geocoder_us: ~
239+ locale: ~
240+ host_ip: []
241+ geoip: []
242+ free_geo_ip: []
243+ mapquest: []
244+ oiorest: []
245+ geocoder_ca: []
246+ geocoder_us: []
234247 ign_openls:
235- api_key: XXXXXXXXX
236- data_science_toolkit: ~
248+ api_key: ~ # Required
249+ data_science_toolkit: []
237250 yandex:
238- locale: xx-XX
239- toponym: XXXXXXXXX
251+ locale: ~
252+ toponym: ~
240253 geo_ips:
241- api_key: XXXXXXXXX
242- geo_plugin: ~
254+ api_key: ~
255+ geo_plugin: []
243256 maxmind:
244- api_key: XXXXXXXXX
245- # Caching Layer
246- cache:
247- provider: openstreetmaps
248- adapter: some_service_id
249- lifetime: 86400
250- locale: %locale%
257+ api_key: ~ # Required
258+ maxmind_binary:
259+ binary_file: ~ # Required
260+ open_flag: ~
251261 chain:
252- providers: [free_geo_ip, host_ip ]
262+ providers: [ ]
253263` ` `
254264
255265
0 commit comments