public function prepareMap($id, $size = 'medium') { if ($pg === false) { // missing place_geometry // TO DO: Fix this later return false; } $center = new stdClass(); Yii::import('ext.gmap.*'); $gMap = new EGMap(); $gMap->setJsName('map_region'); switch ($size) { case 'small': $gMap->width = '200'; $gMap->height = '200'; $gMap->zoom = 13; $gMap->mapTypeControl = false; break; default: $gMap->width = '300'; $gMap->height = '300'; $gMap->zoom = 13; } $gMap->setCenter($center->lat, $center->lon); $coords = PlaceGeometry::model()->string_to_coords($pg['region']); if (count($coords) > 1) { $polygon = new EGMapPolygon($coords); $gMap->addPolygon($polygon); } else { // Create marker with label $marker = new EGMapMarkerWithLabel($center->lat, $center->lon, array('title' => 'Here!')); $gMap->addMarker($marker); } return $gMap; }