protected function renderPopupMap()
    {
        $gMap = new EGMap();
        $gMap->setJsName('hgeomap');
        $gMap->addGlobalVariable('hgmarker');
        $gMap->width = isset($this->popupOptions['mapWidth']) ? $this->popupOptions['mapWidth'] : '100%';
        $gMap->height = isset($this->popupOptions['mapHeight']) ? $this->popupOptions['mapHeight'] : '600px';
        $gMap->zoom = 6;
        $gMap->setCenter($this->latitude, $this->longitude);
        $gMap->addEvent(new EGMapEvent('click', 'function(e){panToMap(geomap,e.latLng,hgeomap);}', false));
        $gMap->appendMapTo('#popup-map');
        $this->popupOptions['width'] = isset($this->popupOptions['width']) ? $this->popupOptions['width'] : '800px';
        $afterInit = array('hgmarker = new google.maps.Marker({
				position: hgeomap.getCenter(),
				map: hgeomap,
				draggable: true
			});', 'google.maps.event.addListener(hgmarker, "dragend", function(e) {
				panToMap(geomap,e.latLng,hgeomap);
			});', '$("#open-big-map").click(function(e){
				e.preventDefault();
				$("#hgeomap").dialog({resizable:false,title:"Location",width:"' . $this->popupOptions['width'] . '"});
				google.maps.event.trigger(hgeomap, "resize");
				hgeomap.setCenter(geomap.getCenter());
				return false;
			});');
        echo CHtml::openTag('div', array('id' => 'hgeomap', 'style' => 'display:none'));
        if (isset($this->popupOptions['searchBox']) && $this->popupOptions['searchBox']) {
            $this->renderAddressSearchBox('hgeoaddress');
        }
        if (!is_array($this->afterInitEvents)) {
            $this->afterInitEvents = array($this->afterInitEvents);
        }
        $gMap->renderMap(array_merge($this->afterInitEvents, $afterInit));
        echo '<div id="popup-map" ></div>';
        echo CHtml::closeTag('div');
    }
$marker->labelStyle=$label_options;
$marker->draggable=true;
$marker->labelClass='labels';
$marker->raiseOnDrag= true;
 
$marker->setLabelAnchor(new EGMapPoint(22,0));
 
$marker->addHtmlInfoWindow($info_window_b);
 
$gMap->addMarker($marker);
 
// enabling marker clusterer just for fun
// to view it zoom-out the map
$gMap->enableMarkerClusterer(new EGMapMarkerClusterer());
 
$gMap->renderMap();
?>
<style type="text/css">
.labels {
   color: red;
   background-color: white;
   font-family: "Lucida Grande", "Arial", sans-serif;
   font-size: 10px;
   font-weight: bold;
   text-align: center;
   width: 40px;     
   border: 2px solid black;
   white-space: nowrap;
}
</style>
Exemple #3
0
    $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');
?>
        <?php