Yii Framework Forum: Problema Con Egmap Y Multiples Capas Kml - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problema Con Egmap Y Multiples Capas Kml Rate Topic: -----

#1 User is offline   periko_0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 20-May 13

Posted 14 June 2013 - 03:00 AM

Buenas,

Estoy usando la extensión egmap de Yii. Intento crear un mapa que carge dos ficheros kml, pero el resultado es que solo muestra el ultimo kml introducido en el código. ¿Alguna idea?. ¿Qué hago mal?. Gracias!!

El fragmento del controlador:

public function actionView($id)
	{
            $model = $this->loadModel($id);
          
            $fileMapa = Yii::app()->params['dirMapas'].$model->id.'.kml';

            //echo Yii::getPathOfAlias('webroot').DIRECTORY_SEPARATOR.$fileMapa;
            if(file_exists($fileMapa)) {
                $criteria = new CDbCriteria();
                $criteria->compare('id_zona', (int)$model->id);
                $seniales = $seniales = Ensal::model()->findAll($criteria);
                Yii::import('ext.gmap.*');
                
                $gMap = new EGMap();
                $gMap->setWidth('100%');
                $gMap->setHeight('600px');
                $gMap->zoom = 10;
                $mapTypeControlOptions = array(
                    'position'=> EGMapControlPosition::LEFT_BOTTOM,
                    'style'=>EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU,
                    
                );
                
                $options = array(
                    'mapTypeId'=> EGMap::TYPE_HYBRID,
                );
                $gMap->setOptions($options);
 
                $gMap->mapTypeControlOptions= $mapTypeControlOptions;
                $gMap->enableKMLService(Yii::app()->getBaseUrl(true).'/'.$fileMapa, true);
                //echo Yii::app()->getBaseUrl(true).'/'.$fileMapa
                //$gMap->enableKMLService('http://127.0.0.1/'.$fileMapa, true);
                
                // Si existe la capa de red la cargamos
                $fileRed = Yii::app()->params['dirMapas'].$model->id.'-red.kml';
                //print $fileRed;
                if(file_exists($fileRed)) 
                    $gMap->enableKMLService(Yii::app()->getBaseUrl(true).'/'.$fileRed, true);
                
                    
                // Horario nocturno
.....

0

#2 User is offline   periko_0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 20-May 13

Posted 17 June 2013 - 02:17 AM

¿Alguien me puede echar una mano?
0

#3 User is offline   periko_0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 20-May 13

Posted 25 June 2013 - 07:28 AM

Sigo sin lograrlo.
0

#4 User is offline   Aaron Meis S. 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 21-June 13

Posted 25 June 2013 - 12:00 PM

hola como estas mira solo te pone el ultimo $gMap->enableKMLService por que almacenas en la ultima posición (variable) no esta mal el código solo no lo maneja como arreglo, aqui lo que te recomiendo es juntar los kml o también puedes implementar una especie de opción 1 ,2 dependiendo del kml que quieran mira, deja ver si lo podemos manejar como un arreglo pero la verdad no creo saludos :rolleyes:
0

#5 User is offline   Aaron Meis S. 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 21-June 13

Posted 25 June 2013 - 12:05 PM

si por lo que acabo de revisar en las funciones de Yii lo tienes que hacer por opciones o juntar los kml
/**
*
* Enables LatLonControl plugin
*
*/
public function enableKMLService( $url, $localhost = false ){
if( true === $localhost )
$this->registerPlugin( 'EGMapKMLService' );
$this->_kmlService = new EGMapKMLService($url);
}

te dejo la funcion de enableKMLService saludos
1

#6 User is offline   periko_0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 20-May 13

Posted 26 June 2013 - 01:23 AM

View PostAaron Meis S., on 25 June 2013 - 12:05 PM, said:

si por lo que acabo de revisar en las funciones de Yii lo tienes que hacer por opciones o juntar los kml
/**
*
* Enables LatLonControl plugin
*
*/
public function enableKMLService( $url, $localhost = false ){
if( true === $localhost )
$this->registerPlugin( 'EGMapKMLService' );
$this->_kmlService = new EGMapKMLService($url);
}

te dejo la funcion de enableKMLService saludos


¿Cómo por opciones?. No lo entiendo...
0

#7 User is offline   periko_0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 20-May 13

Posted 26 June 2013 - 02:32 AM

Metiendolo en un solo kml no lo hago funcionar, sólo carga el fichero tres.kml. Pero lo más curioso es que si en el fichero sólo dejo el 3-red.kml me muestra el tres.kml... y he borrado caché y los assets por si tenía algo que ver.

Tengo lo siguiente:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
  <NetworkLink>
    <Link>
     <href>tres.kml</href>
    </Link>
   </NetworkLink>

   <NetworkLink>
    <Link>
     <href>3-red.kml</href>
    </Link>
   </NetworkLink>
</Document>
</kml>


¿Es correcto?
0

#8 User is offline   periko_0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 20-May 13

Posted 26 June 2013 - 06:08 AM

Solucionado.

Aquí os dejo la solución

<?php
/**
 * 
 * EGMapKMLService Class
 * 
 * @link http://gmaps-samples-v3.googlecode.com/svn/trunk/latlng-to-coord-control/latlng-to-coord-control.html
 * 
 * 
 * @author Antonio Ramirez Cobos
 *
 * 
 * @copyright 
 * 
 * Copyright (c) 2010 Antonio Ramirez Cobos
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
 * and associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 
 * subject to the following conditions:
 * The above copyright notice and this permission notice shall be included in all copies or substantial 
 * portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
 * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */
class EGMapKMLService extends EGMapBase 
{
	
	protected $url;
        protected $url1;
	
	function __construct( $url, $url1 ){
		$urlValidator = new CUrlValidator();
                if($urlValidator->validateValue($url))
                    $this->url = $url;
                else 	
                    throw new CException( Yii::t('EGMap','EGMapKMLService.url must be a valid URL address') );
                if (!empty($url1)) {
                    if($urlValidator->validateValue($url))
                        $this->url1 = $url1;
                    else
                        throw new CException( Yii::t('EGMap','EGMapKMLService.url must be a valid URL address') );
                }
	}
	
	/**
	 * @return string Create new control to display latlng and coordinates under mouse.
	 */
	public function toJs( $map_js_name = 'map' )
	{       
                //$aleatorio = rand(1000,99999);
            $return = 'var '.$this->getJsName().'= new google.maps.KmlLayer(\''.$this->url.'\');'.PHP_EOL;
            $return .= $this->getJsName().'.setMap('.$map_js_name.');'.PHP_EOL;
            if (!empty($this->url1)) {
                $return .= 'var '.$this->getJsName().'= new google.maps.KmlLayer(\''.$this->url1.'\');'.PHP_EOL;
                $return .= $this->getJsName().'.setMap('.$map_js_name.');'.PHP_EOL;
            }
            return  $return;
  	}
}

	public function enableKMLService($url, $url1 = '', $localhost = false)
	{
		if (true === $localhost)
			$this->registerPlugin('EGMapKMLService');
		$this->_kmlService = new EGMapKMLService($url, $url1);
	}

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users