Example #1
0
 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;
 }
Example #2
0
$gMap->setCenter(39.721089311812094, 2.91165944519042);
 
// Create GMapInfoWindows
$info_window_a = new EGMapInfoWindow('<div>I am a marker with custom image!</div>');
$info_window_b = new EGMapInfoWindow('Hey! I am a marker with label!');
 
$icon = new EGMapMarkerImage("http://google-maps-icons.googlecode.com/files/gazstation.png");
 
$icon->setSize(32, 37);
$icon->setAnchor(16, 16.5);
$icon->setOrigin(0, 0);
 
// Create marker
$marker = new EGMapMarker(39.721089311812094, 2.91165944519042, array('title' => 'Marker With Custom Image','icon'=>$icon));
$marker->addHtmlInfoWindow($info_window_a);
$gMap->addMarker($marker);
 
// Create marker with label
$marker = new EGMapMarkerWithLabel(39.821089311812094, 2.90165944519042, array('title' => 'Marker With Label'));
 
$label_options = array(
  'backgroundColor'=>'yellow',
  'opacity'=>'0.75',
  'width'=>'100px',
  'color'=>'blue'
);
 
/*
// Two ways of setting options
// ONE WAY:
$marker_options = array(
Example #3
0
    $map->height = 470;
    $map->zoom = 8;
    $map->setCenter(39.737827146489174, 3.2830574338912477);
    $map->mapTypeControl = false;
    $map->panControl = false;
    $map->streetViewControl = false;
    $latitudeAttributeName = 'latitude';
    $longitudeAttributeName = 'longitude';
    $marker = new EGMapMarker($model->latitude, $model->longitude, array(), 'marker', array('dragevent' => new EGMapEvent('dragend', strtr('function(event){$("input[name=\\"{latName}\\"]").val(event.latLng.lat());$("input[name=\\"{lngName}\\"]").val(event.latLng.lng());}', array('{latName}' => CHtml::resolveName($model, $latitudeAttributeName), '{lngName}' => CHtml::resolveName($model, $longitudeAttributeName))), false, EGMapEvent::TYPE_EVENT_DEFAULT)));
    // the setter does not perform the special handling of 'title' that the constructor gets via setOptions().
    $marker->title = "'{$model->name}'";
    $marker->icon = new EGMapMarkerImage(Yii::app()->request->baseUrl . '/images/map-marker-blue.png');
    $marker->icon->setSize(59, 54);
    $marker->icon->setAnchor(59 / 2, 54);
    $marker->draggable = true;
    $map->addMarker($marker);
    $fitBounds = strtr('map.fitBounds(new google.maps.LatLngBounds(new google.maps.LatLng({sw.lat}, {sw.lng}), new google.maps.LatLng({ne.lat}, {ne.lng})));', array('{sw.lat}' => $model->region->southwest_latitude, '{sw.lng}' => $model->region->southwest_longitude, '{ne.lat}' => $model->region->northeast_latitude, '{ne.lng}' => $model->region->northeast_longitude));
    $map->renderMap(array($fitBounds));
}
$form = $this->beginWidget('CActiveForm', array('id' => 'location-form', 'enableAjaxValidation' => false));
?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php 
echo $form->errorSummary($model);
?>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'created_by_user_id');