EGMap 2.0 Google Maps Extension

How to add different types of layers in Egmap.

I am using this article

www.ramirezcobos.com/tag/egmap/

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…

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

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>)

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_<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='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();

        ?>

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.

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.

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'<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />{'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

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'<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />{'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"<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />{"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

Help me please.

How open map in new modal window after click on the link "Show map"?

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.

Hello. I want multiple Points in my map dynamically.i use following code




$jobs= JobLocation::model()->findAllByAttributes(array('assign_to'=>Yii::app()->user->id,'assign_date'=>date('Y-m-d'))); 

    

     if(!empty($jobs))

     {

     $lattitude=array();

     $longitude=array();

     foreach ($jobs as $r)

     {

         $lattitude[]=$r->jobMaster->latitude;

         $longitude[]=$r->jobMaster->longitude;

     }

     sort($lattitude);

     rsort($longitude);

         

     $a1=$lattitude[0];

     $a2=$longitude[0];

    

     Yii::import('ext.EGMap.*'); 

     $gMap = new EGMap();

     $gMap->setWidth('100%');

     $gMap->setHeight(393);

     

     $gMap->zoom = 4;

     $mapTypeControlOptions = array('position'=> EGMapControlPosition::LEFT_BOTTOM, 'style'=>EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU );


     $gMap->mapTypeControlOptions= $mapTypeControlOptions;


     //$gMap->setCenter(-20.73, 151.20);

     $gMap->setCenter($a1, $a2);

     

     $icon = new EGMapMarkerImage("http://google-maps-icons.googlecode.com/files/gazstation.png");

     $icon->setSize(100, 100);

     $icon->setAnchor(16, 16.5);

     $icon->setOrigin(0, 0);

     

     foreach ($jobs as $location)

     {

            $lat=$location->jobMaster->latitude;

            $long=$location->jobMaster->longitude;

            

            // Create GMapInfoWindows

            $msg='<b>'.$location->jobMaster->customer_name.'</b>';

            $msg .= '<br>'.$location->jobMaster->location;

            $info_window_b = new EGMapInfoWindow($msg);


            // Create marker with label

            $marker = new EGMapMarkerWithLabel($lat, $long, array('title' => $location->jobMaster->customer_name));


            $label_options = array(

              'backgroundColor'=>'yellow',

              'opacity'=>'0.75',

              'width'=>'100px',

              'color'=>'blue'

            );

            

            $marker->labelContent= $location->jobMaster->customer_name;

            $marker->labelStyle=$label_options;

            $marker->draggable=true;

            $marker->labelClass='labels';

            $marker->raiseOnDrag= true;

            $marker->setLabelAnchor(new EGMapPoint(22,0));

            $marker->addHtmlInfoWindow($info_window_<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='B)' />;

            $gMap->addMarker($marker);


            // enabling marker clusterer just for fun

            // to view it zoom-out the map

            $gMap->enableMarkerClusterer(new EGMapMarkerClusterer());


            }

            $gMap->renderMap();

     }



following i result i get.

but i want result like second image. Hows Possible in EGMap.??

Hi,

I have used the extension for loading multiple map in a search result page. It is very slow to load. So I tried to show the map in JQuery UI Modal dialog by clicking a link(ajax). I am getting error "Reference Error: google is not defined". Please help me to fix this.

Thanks

Hi,

Thanks for great work. Its really easy to use.

I am facing problem to display places into the map from my search result. From your sample code, its showing the way to draw the path among several locations.

Would anyone please help me to find out the solution for my issue.

Thanks.

Hi,

I need implement auto center/zoom.

Searching, I found it:

"

var bounds = new google.maps.LatLngBounds();

Then for each marker, extend your bounds object:

bounds.extend(PointLatLng);

map.fitBounds(bounds);

"

How to use this code??

thanks

Just recently all of my sites have been stalling out whenever trying to use the Geocode portion of this extension. Everything else seems to work just fine. Basically, whenever the page needs to find the longitude and latitude of a particular address, it does nothing until it eventually times out. It has been working perfectly for a quite a long while up until recently.

Is anyone else having this problem? Has google changed something with their api that needs to be changed in this extension or my site?

Thanks!