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; }
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'); }
</div> </div> <div class="col-md-6"> <?php $this->widget('booster.widgets.TbCarousel', array('items' => array(array('image' => Yii::app()->request->baseUrl . '/images/carousel/slide-1.jpg'), array('image' => Yii::app()->request->baseUrl . '/images/carousel/slide-2.jpg'), array('image' => Yii::app()->request->baseUrl . '/images/carousel/slide-3.jpg')))); ?> </div> <div class="col-md-6"> <?php Yii::import('application.extensions.EGMAP.*'); $gMap = new EGMap(); $gMap->setJsName('test_map'); $gMap->width = '100%'; $gMap->height = 300; $gMap->zoom = 11; $gMap->setCenter(39.737827146489174, 3.2830574338912477); $info_box = new EGMapInfoBox('<div style="color:#fff;border: 1px solid black; margin-top: 8px; background: #000; padding: 5px;">I am a marker with info box!</div>'); $info_box->pixelOffset = new EGMapSize('0', '-140'); $info_box->maxWidth = 0; $info_box->boxStyle = array('width' => '"280px"', 'height' => '"120px"', 'background' => '"url(http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/examples/tipbox.gif) no-repeat"'); $info_box->closeBoxMargin = '"10px 2px 2px 2px"'; $info_box->infoBoxClearance = new EGMapSize(1, 1); $info_box->enableEventPropagation = '"floatPane"'; $marker = new EGMapMarker(39.721089311812094, 2.91165944519042, array('title' => 'Marker With Info Box')); $marker->addHtmlInfoBox($info_box); $gMap->addMarker($marker); $gMap->renderMap();
<?php /* @var $this LocationController */ /* @var $model Location */ /* @var $form CActiveForm */ ?> <div class="form"> <?php if ($model->region) { Yii::import('application.extensions.egmap.*'); Yii::app()->clientScript->registerCoreScript('jquery'); $map = new EGMap(); $map->setJsName('map'); $map->width = '100%'; $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);