public static function createMap($isAppartment = false) { self::$jsVars = ' var mapGMap; var fenWayPanorama; var markersGMap = []; var markersForClasterGMap = []; var infoWindowsGMap = []; var latLngList = []; var markerClusterGMap; '; self::$jsCode = ' var centerMapGMap = new google.maps.LatLng(' . param('module_apartments_gmapsCenterY', 55.75411314653655) . ', ' . param('module_apartments_gmapsCenterX', 37.620717508911184) . '); mapGMap = new google.maps.Map(document.getElementById("googleMap"), { zoom: ' . ($isAppartment ? param('module_apartments_gmapsZoomApartment', 15) : param('module_apartments_gmapsZoomCity', 11)) . ', center: centerMapGMap, mapTypeId: google.maps.MapTypeId.ROADMAP }); '; }
public static function createMap($isAppartment = false) { //Yii::app()->getClientScript()->registerScriptFile('https://maps.google.com/maps/api/js??v=3.5&sensor=false&language='.Yii::app()->language.'', CClientScript::POS_END); //Yii::app()->getClientScript()->registerScriptFile('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js', CClientScript::POS_END); self::$jsVars = ' var mapGMap; var fenWayPanorama; var markersGMap = []; var markersForClasterGMap = []; var infoWindowsGMap = []; var latLngList = []; var markerClusterGMap; '; self::$jsCode = ' var centerMapGMap = new google.maps.LatLng(' . param('module_apartments_gmapsCenterY', 55.75411314653655) . ', ' . param('module_apartments_gmapsCenterX', 37.620717508911184) . '); mapGMap = new google.maps.Map(document.getElementById("googleMap"), { zoom: ' . ($isAppartment ? param('module_apartments_gmapsZoomApartment', 15) : param('module_apartments_gmapsZoomCity', 11)) . ', center: centerMapGMap, mapTypeId: google.maps.MapTypeId.ROADMAP }); '; }
public function actionGmap($id, $model = null) { if ($model === null) { $model = $this->loadModel($id); } $result = CustomGMap::actionGmap($id, $model, $this->renderPartial('_marker', array('model' => $model), true), true); if ($result) { return $this->renderPartial('_gmap', $result, true); } return ''; }
public function actionGmap($id) { $model = $this->loadModelUserAd($id); $result = CustomGMap::actionGmap($id, $model, $this->renderPartial('//../modules/apartments/views/backend/_marker', array('model' => $model), true)); if ($result) { return $this->renderPartial('//../modules/apartments/views/backend/_gmap', $result, true); } }
public function run() { Yii::app()->getModule('apartments'); $criteria = $this->criteria ? $this->criteria : new CDbCriteria(); if ($this->filterOn) { Yii::app()->controller->aData['searchOnMap'] = true; $this->renderFilter($criteria); } if (param('useYandexMap', 1)) { echo $this->render('application.modules.apartments.views.backend._ymap', '', true); CustomYMap::init()->createMap(); } elseif (param('useGoogleMap', 1)) { CustomGMap::createMap(); } else { echo '<div id="osmap"></div>'; CustomOSMap::createMap(); } $lang = Yii::app()->language; $criteria->select = 'lat, lng, id, type, address_' . $lang . ', title_' . $lang . ', address_' . $lang; $ownerActiveCond = ''; if (param('useUserads')) { $ownerActiveCond = ' AND owner_active = ' . Apartment::STATUS_ACTIVE . ' '; } $criteria->addCondition('lat <> "" AND lat <> "0" AND active=' . Apartment::STATUS_ACTIVE . ' AND (owner_id=1 OR owner_id>1 ' . $ownerActiveCond . ')'); $apartments = Apartment::findAllWithCache($criteria); if (param('useYandexMap', 1)) { $lats = array(); $lngs = array(); foreach ($apartments as $apartment) { $lats[] = $apartment->lat; $lngs[] = $apartment->lng; CustomYMap::init()->addMarker($apartment->lat, $apartment->lng, $this->render('application.modules.apartments.views.backend._marker', array('model' => $apartment), true), true, $apartment); } if ($lats && $lngs) { CustomYMap::init()->setBounds(min($lats), max($lats), min($lngs), max($lngs)); if ($this->withCluster) { CustomYMap::init()->setClusterer(); } else { CustomYMap::init()->withoutClusterer(); } } else { $minLat = param('module_apartments_ymapsCenterX') - param('module_apartments_ymapsSpanX') / 2; $maxLat = param('module_apartments_ymapsCenterX') + param('module_apartments_ymapsSpanX') / 2; $minLng = param('module_apartments_ymapsCenterY') - param('module_apartments_ymapsSpanY') / 2; $maxLng = param('module_apartments_ymapsCenterY') + param('module_apartments_ymapsSpanY') / 2; CustomYMap::init()->setBounds($minLng, $maxLng, $minLat, $maxLat); } CustomYMap::init()->changeZoom(0, '+'); CustomYMap::init()->processScripts(true); } elseif (param('useGoogleMap', 1)) { foreach ($apartments as $apartment) { CustomGMap::addMarker($apartment, $this->render('application.modules.apartments.views.backend._marker', array('model' => $apartment), true)); } if ($this->withCluster) { CustomGMap::clusterMarkers(); } CustomGMap::setCenter(); CustomGMap::render(); } elseif (param('useOSMMap', 1)) { foreach ($apartments as $apartment) { CustomOSMap::addMarker($apartment, $this->render('application.modules.apartments.views.backend._marker', array('model' => $apartment), true)); } if ($this->withCluster) { CustomOSMap::clusterMarkers(); } CustomOSMap::setCenter(); CustomOSMap::render(); } }