Yii Framework Forum: EGMap 2.0 Google Maps Extension - Yii Framework Forum

Jump to content

  • (13 Pages)
  • +
  • « First
  • 11
  • 12
  • 13
  • You cannot start a new topic
  • You cannot reply to this topic

EGMap 2.0 Google Maps Extension Objet-oriented PHP abstraction to the Google Maps API to ease the proc Rate Topic: ***** 5 Votes

#241 User is offline   Shamsher 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 26-August 13
  • Location:Pune, Maharahtra, India

Posted 25 February 2014 - 04:46 AM

How to add different types of layers in Egmap.
I am using this article
www.ramirezcobos.com/tag/egmap/
0

#242 User is offline   leonano 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 22-April 14

Posted 23 April 2014 - 09:34 AM

View Postbutching, on 11 May 2012 - 06:10 AM, said:

Complete step for Autocomplete script that I include ()
Step 1: put the script on the EGMap extension
Step 2: Add this function on EGMap.php
public function addAutocomplete($inputId = null)
{
   
    if ($inputId === null)
      $autocomplete = new EGMapAutocomplete();
    else
      $autocomplete = new EGMapAutocomplete($inputId);

    $this->resources->add('autocomplete', new CTypedList('EGMapAutocomplete'));    
    $this->resources->itemAt('autocomplete')->add($autocomplete);
}
public function getAutocompleteJs()
{
    $return = '';
    if (null !== $this->resources->itemAt('autocomplete'))
    {
        foreach ($this->resources->itemAt('autocomplete') as $autocomplete)
        {
            $return .= $autocomplete->toJs($this->getJsName());
            $return .= "\n      ";
        }
    }
    return $return;
}

Step 4: Still in the EGMap.php find the function public function registerMapScript and add this line
$params .= '&libraries=places';

before
CGoogleApi::init();

and this line
$init_events[] = $this->getAutocompleteJs();

after the other $init_events[]

and to call the autocomplete.. use this
$gMap->addAutocomplete();

You must have input field with id searchTextField or if you want customid just put it inside the
$gMap->addAutocomplete($customid);


*This script assumes you already have a default marker with info window.
You can still play with script base on your needs

I'm Sorry, but I cannot understand (i'm new here :D) but I follow all the steps, but when i have the _form view with a address input text field, how can i call the autocomplete? I try in different way, but nothing happened! You wrote that i alredy have a default marker and a info window... I had! But non autocomplete appears. If I put a zii widget whit the autocomplete it has autocomplete=off... Crazy....
0

#243 User is offline   vTwoRockman 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 14-December 13
  • Location:Yazd, Iran

Posted 25 April 2014 - 04:26 AM

hi .

first, sry for my rip english.

i want change map center by searching in text box , how do it?

i process and get latitude and longitude in server by ajax request, how change center with javascript?

tnx
0

#244 User is offline   whyteaz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 06-May 14

Posted 07 May 2014 - 03:30 AM

hi, i m using egmapinfobox with some image inside the marker. How could i have those image clickable to a image viewer? I know how to do it in php, html but not in egmap. I already go javascript to handle the image viewer but it seems that i can't run that within egmap.

Any enlightenment will be appreciate :rolleyes:


code:

$info_box = new EGMapInfoBox(<div><a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a></div>)
0

#245 User is offline   boot_strap 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 67
  • Joined: 05-December 13

Posted 11 May 2014 - 06:10 AM

Hello folks am new with yii
I just started to use Egmap for Yii and Im adding a groupe of marker (shopping centers, hospitals hotels etc) and I am wondering how to proceed to allow the user to select which marker he would like to display in the map (all, juste hospitals or just restaurans etc..)

        <?php
        //
        // ext is your protected.extensions folder
        // gmaps means the subfolder name under your protected.extensions folder
        //  
        Yii::import('ext.Egmap.*');
         
        $gMap = new EGMap();
        $gMap->zoom = 15;
        $gMap->setHeight (600);
        $gMap->setWidth (1138);
         
        $gMap->setCenter(13.732304,100.567122);
      
    $icon = new EGMapMarkerImage("/graphics/gmap/stores/mall.png");
    $icon_b = new EGMapMarkerImage("/graphics/gmap/Health_Education/hospital-building.png");
    $icon_c = new EGMapMarkerImage("/graphics/gmap/transportation/highway.png");
    $icon_d = new EGMapMarkerImage("/graphics/gmap/Restaurants_Bars_Hotels/hotel_0star.png");
    
        // Create marker
        $marker = new EGMapMarker(13.737510, 100.560485, array('title' => 'MALL','icon'=>$icon));
        //$marker->addHtmlInfoWindow($info_window_a);
        $gMap->addMarker($marker);
        
        $marker = new EGMapMarkerWithLabel(13.734938, 100.576620, array('title' => 'Hospital','icon'=>$icon_B));
        //$marker->addHtmlInfoWindow($info_window_a);
        $gMap->addMarker($marker);
        
        $marker = new EGMapMarkerWithLabel(13.742694, 100.550510, array('title' => 'EcpressWay','icon'=>$icon_c));
        //$marker->addHtmlInfoWindow($info_window_a);
        $gMap->addMarker($marker);
        
        $marker = new EGMapMarkerWithLabel(13.737639, 100.559360, array('title' => 'Hotel','icon'=>$icon_d));
        //$marker->addHtmlInfoWindow($info_window_a);
        $gMap->addMarker($marker);
         
        $gMap->addMarker($marker);
         
        // enabling marker clusterer just for fun
        // to view it zoom-out the map
        $gMap->enableMarkerClusterer(new EGMapMarkerClusterer());
         
        $gMap->renderMap();
        ?>

0

#246 User is offline   mem 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 16-December 11

Posted 13 May 2014 - 01:31 PM

Are you able to center several markers on map?

  //import
    Yii::import('ext.egmap.*');

    //basic setup
    $gMap = new EGMap();
    $gMap->setWidth(953);
    $gMap->setHeight(552);
    $gMap->zoom = 16;
    $gMap->setCenter(38.257818,-7.992712);

    //setup info windows:
    $info_window_a = new EGMapInfoWindow('<div>I am a marker with custom image!</div>');


    //setup marker icon
    $icon = new EGMapMarkerImage("/images/experiences/iconLocal.png");
    $icon->setSize(30, 30);
    $icon->setAnchor(16, 16.5);
    $icon->setOrigin(0, 0);

    //setup markers
    $markerA = new EGMapMarker(38.257818, -7.992712, array('title' => 'Marker A - With Custom Image','icon'=>$icon));
    $markerA->addHtmlInfoWindow($info_window_a);
    $gMap->addMarker($markerA);

    $markerB = new EGMapMarker(38.257818, -7.99333, array('title' => 'Marker B - With Custom Image','icon'=>$icon));
    $markerB->addHtmlInfoWindow($info_window_a);
    $gMap->addMarker($markerB);

    //place them together - but the centerAndZoomOnMarkers seems to
    $markers = array($markerA, $markerB);

    //try to map center and zoom them:
     $gMap->centerAndZoomOnMarkers();



I see no centered map after rendering.
Am I doing something wrong?


Answer:
$gMap->centerAndZoomOnMarkers(0.5);
Need to set some values on that method call.
Solved.
0

#247 User is offline   Preacher 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 01-October 11

Posted 19 May 2014 - 01:19 PM

Great extension

How do you default to satellite view?
Also, can you have the balloon open by default?
0

#248 User is offline   Preacher 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 01-October 11

Posted 19 May 2014 - 02:09 PM

View PostPreacher, on 19 May 2014 - 01:19 PM, said:

Great extension

How do you default to satellite view?
Also, can you have the balloon open by default?



$gMap->mapTypeId = EGMap::TYPE_ROADMAP;

Found it.
0

#249 User is offline   funthere 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 16-April 13

Posted 21 July 2014 - 10:25 PM

I want to make the infoWindow appear when hover/mouseover to multi-polygon(different infoWindow in different polygon) and data in infoWindow retrieve from database. I've try to implement by this code in view:
$info = new EGMapEvent('mouseover', "function (event) { $.ajax({
                                            'type':'GET',
                                             'url':'".$this->createUrl('tabelpoly/view',array('id'=>$dataProvider->id))."',
                                            'data':({'lat': event.latLng.lat(), 'lng': event.latLng.lng()}),
                                            'cache':false,
                                        });}", false, EGMapEvent::TYPE_EVENT_DEFAULT);

			
			
			 
			$polygon->addEvent($info);
			$gMap->addPolygon($polygon);


And this code in TabelpolyController:
public function actionView($id)
	{
		$this->render('index',array(
			'dataProvider'=>$this->loadModel($id),
		));
	}

Until this far, nothing's appear when hover to the polygon. Anyone can help me please? Or is there another way to do this? Thank you
0

#250 User is offline   vav 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 19-August 14

Posted 27 August 2014 - 04:44 PM

Help please. this is my view:
<?php

Yii::import('ext.egmap.*');
$gMap = new EGMap();
$gMap->setWidth(880);
$gMap->setHeight(550);
$gMap->zoom = 6;
$mapTypeControlOptions = array(
  'position' => EGMapControlPosition::RIGHT_TOP,
  'style' => EGMap::MAPTYPECONTROL_STYLE_HORIZONTAL_BAR
);
 
$gMap->mapTypeId = EGMap::TYPE_ROADMAP;
$gMap->mapTypeControlOptions = $mapTypeControlOptions;
 
// Preparing InfoWindow with information about our marker.
$info_window_a = new EGMapInfoWindow("<div class='gmaps-label' style='color: #000;'>Hi! I'm your marker!</div>");
 
// Setting up an icon for marker.
$icon = new EGMapMarkerImage("/files/car.png");
 
$icon->setSize(32, 37);
$icon->setAnchor(16, 16.5);
$icon->setOrigin(0, 0);
 
// Saving coordinates after user dragged our marker.
$dragevent = new EGMapEvent('dragend', "function (event) { $.ajax({
                                            'type':'POST',
                                            'url':'".$this->createUrl('catalog/savecoords').'/'.$items->id."',
                                            'data':({'lat': event.latLng.lat(), 'lng': event.latLng.lng()}),
                                            'cache':false,
                                        });}", false, EGMapEvent::TYPE_EVENT_DEFAULT);
 
// If we have already created marker - show it
if ($map) {
 
    $marker = new EGMapMarker($map->lat, $map->lng, array('title' => Yii::t('catalog', $items->type->name),
            'icon'=>$icon, 'draggable'=>true), 'marker', array('dragevent'=>$dragevent));
    $marker->addHtmlInfoWindow($info_window_a);
    $gMap->addMarker($marker);
    $gMap->setCenter($map->lat, $map->lng);
    $gMap->zoom = 16;
 
// If we don't have marker in database - make sure user can create one
} else {
    $gMap->setCenter(38.348850, -0.477551);
 
    // Setting up new event for user click on map, so marker will be created on place and respectful event added.
    $gMap->addEvent(new EGMapEvent('click',
            'function (event) {var marker = new google.maps.Marker({position: event.latLng, map: '.$gMap->getJsName().
            ', draggable: true, icon: '.$icon->toJs().'}); '.$gMap->getJsName().
            '.setCenter(event.latLng); var dragevent = '.$dragevent->toJs('marker').
            '; $.ajax({'.
              '"type":"POST",'.
              '"url":"'.$this->createUrl('catalog/savecoords')."/".$items->id.'",'.
              '"data":({"lat": event.latLng.lat(), "lng": event.latLng.lng()}),'.
              '"cache":false,'.
            '}); }', false, EGMapEvent::TYPE_EVENT_DEFAULT_ONCE));
}
$gMap->renderMap(array(), Yii::app()->language);
?>


my action:
 public function actionSavecoords()
        {
            $model=$this->loadModel($id);

        // Uncomment the following line if AJAX validation is needed
                // 
        // $this->performAjaxValidation($model);
            if(isset ($_GET['lat']))
                $model->lat = $_GET['lat'];
            if(isset ($_GET['lat']))
                $model->lng = $_GET['lng'];
            if($model->save())
                {
                    echo 'Thank you for registring your place with '.Yii::app()->name;  
                }
                $this->render('view',array(
            'model'=>$model,
        ));
        }

But map not displaying, i watch brown zone
0

#251 User is offline   vav 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 19-August 14

Posted 21 September 2014 - 04:51 PM

Help me please.
How open map in new modal window after click on the link "Show map"?
0

#252 User is offline   vTwoRockman 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 14-December 13
  • Location:Yazd, Iran

Posted 29 October 2014 - 02:56 PM

hi guys,
A problem,
in directions, I can add to the map just 10 points
If i add more than 10 points of the card simply does not appear, How to overcome this limitation?

Thank you.
0

Share this topic:


  • (13 Pages)
  • +
  • « First
  • 11
  • 12
  • 13
  • 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