Skip to content

Commit

Permalink
Fixing issue where when id was provided, no DIV was produced. Fixing …
Browse files Browse the repository at this point in the history
…issue where addresses could leave out a ZIP, thus producing a save error in DB
  • Loading branch information
mariano committed Oct 15, 2009
1 parent 6d0d506 commit 1add366
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions models/behaviors/geocodable.php
Expand Up @@ -270,8 +270,10 @@ public function geocode($model, $address, $save = true) {
$data[$model->alias][$settings['fields']['latitude']] = $coordinates[0];
$data[$model->alias][$settings['fields']['longitude']] = $coordinates[1];

$model->create();
$model->save($data);
if (!empty($data[$model->alias][$settings['fields']['state']])) {
$model->create();
$model->save($data);
}
}

return $coordinates;
Expand Down
5 changes: 4 additions & 1 deletion views/helpers/geomap.php
Expand Up @@ -44,7 +44,7 @@ public function map($center = null, $markers = array(), $parameters = array()) {
'width' => 500,
'height' => 300,
'zoom' => 10,
'div' => array(),
'div' => array('class'=>'map'),
'type' => 'street',
'layout' => Configure::read('Geocode.layout'),
'layouts' => array(
Expand Down Expand Up @@ -79,6 +79,9 @@ public function map($center = null, $markers = array(), $parameters = array()) {

if (empty($parameters['id'])) {
$parameters['id'] = 'map_' . Security::hash(uniqid(time(), true));
}

if ($parameters['div'] !== false) {
$out .= $this->Html->div(
!empty($parameters['div']['class']) ? $parameters['div']['class'] : null,
'<!-- ' . $service . ' map -->',
Expand Down

0 comments on commit 1add366

Please sign in to comment.