EGMap 2.0 Google Maps Extension

The github location of this extension has now changed to https://github.com/2amigos/egmap

I am very sorry for all you waiting for some support. Not having much time nowadays.

Please, accept my apologies

Do you have CURL installed? can you show a debug message? like what is happening when the CURL call is performed?

Cheers

Just put an iframe there and put its src attribute to point to a controller that renderPartial the view… it will work.

to ge the javascript instance of a map, you need to make use of the ->getJsName(), that will return its ID. EGMap defaults to EGMap{counter} if you do not set its ID. The easiest solution is to set its ID (ie myEGMap) and then make use of that name to get its javascript instance.

Please check this example: https://github.com/2amigos/egmap/blob/master/EGMapGeocodeTool.php (it may have some issues out of the box)

check this class maybe it provides you with clues https://github.com/2amigos/egmap/blob/master/EGMapGeocodeTool.php

You just need to add a global variable to the map https://github.com/2amigos/egmap/blob/master/EGMap.php#L933

Then, in order to create the marker add the initialization code on its afterInits parameter https://github.com/2amigos/egmap/blob/master/EGMap.php#L664 when you render the map:




$myMap->renderMap(array('GMapMarker1 = new google.maps.Marker({map:map, position:new google.maps.LatLng(52.444977, 13.2910249), draggable:true});');



– not tested

Cheers

Hi Antonio:) Thanks for this great extension :)

I asked a questions earlier but i almost did everything :) It was my question: How can i display multiple markers (from db) which should be displayed on renderPartial (using default Manage view from CRUD - Model::actionAdmin) and quantity of markers should dependent from records displayed by zii.widgets.grid.CGridView (for example: when i click next page on CGridView pagination - markers should be reloaded). I almost did it, but not all:) it’s my actual code:)




<?php

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

$gMap = new EGMap();

$gMap->zoom = 2;

$mapTypeControlOptions = array(

  'position'=> EGMapControlPosition::LEFT_BOTTOM,

  'style'=>EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU

);

$gMap->mapTypeControlOptions= $mapTypeControlOptions;

$gMap->setCenter(39.721089311812094, 2.91165944519042);


$dataProvider=$model->search();

  $i = 0;

  if ( $dataProvider->getData() ) {

  foreach ($dataProvider->getData() as $row) {

  $i++;

  // Create marker

  $marker = new EGMapMarker($row['lat'], $row['lng']);

  $gMap->addMarker($marker);

  }

  }

$gMap->renderMap();

//end of egmap


//start search and gridview


Yii::app()->clientScript->registerScript('search', "

$('.search-button').click(function(){

	$('.search-form').toggle();

	return false;

});

$('.search-form form').submit(function(){

	$('#mapa-grid').yiiGridView('update', {

		data: $(this).serialize()

	});

	return false;

});

");


echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>

<div class="search-form" style="display:none">

<?php $this->renderPartial('_search',array(

	'model'=>$model,

)); ?>

</div><!-- search-form -->


<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'mapa-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'id',

		'idspecies',

		'lat',

		'lng',

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>




It is almost fine, but I’ve got one question:) When i search using search form or navigate in gridview using pagination, or delete record using gridview - markers on map are not changed. How can i make it work ?:)

Thanks and Greetings from Poland:)

Tom

I tried to disable ajax in CGridView, and when i disable ajax, everything works fine. But how make it work, when ajax is enabled ?:)

Thanks :)

How i can apply custom style to map?

Nice work,

am working on an openlayers based Mapping extension that will have several widgets.

I have added the slick data grid and linked it with the openlayers map.

am now working on a search widget so that search results are over-layed on the map via AJAX.

have also managed to put them all in the Jquery UI Layout. which makes it look like extJS.

am trying to make a set of widgets that can be placed in different parts of a view to make different mapping applications:

proposed widgets:

-map


-layer switcher


-feature selector [data table grid]


-query executor [an input field for query and sending results to openlayers]


-legend


-editor


-controllers [zoomer,panner,.....]


-layout

do check the following post if you are interested in contributing to this new mapping extension :D :

http://www.yiiframework.com/forum/index.php/topic/42884-openlayers-mapping-extension/

Hi Antonio! Can I use multiple markers with EGmap? I have an array:

[b]Array

(

[0] =&gt; Array


    (


        [Latitud] =&gt; -34.53627


        [Longitud] =&gt; -58.57105


        [Fecha_Hora] =&gt; 2013-02-10 00:01:50


    )





[1] =&gt; Array


    (


        [Latitud] =&gt; -34.53627


        [Longitud] =&gt; -58.57105


        [Fecha_Hora] =&gt; 2013-02-10 00:06:50


    )





[2] =&gt; Array


    (


        [Latitud] =&gt; -34.53627


        [Longitud] =&gt; -58.57105


        [Fecha_Hora] =&gt; 2013-02-10 00:11:50


    )





[3] =&gt; Array


    (


        [Latitud] =&gt; -34.53627


        [Longitud] =&gt; -58.57105


        [Fecha_Hora] =&gt; 2013-02-10 00:16:50


    )





[4] =&gt; Array


    (


        [Latitud] =&gt; -34.53627


        [Longitud] =&gt; -58.57105


        [Fecha_Hora] =&gt; 2013-02-10 00:21:50


    )





[5] =&gt; Array


    (


        [Latitud] =&gt; -34.53627


        [Longitud] =&gt; -58.57105


        [Fecha_Hora] =&gt; 2013-02-10 00:26:50


    )

)[/b]

I need to use this array with custom markers.

Thank you.

Mauro

ESPAÑOL

[color="#9932CC"]ENGLISH[/color]

Hola, estuvimos trabajando con tu extensión para desarrollar nuestra aplicación, y nos fue de gran ayuda. Muchas gracias por compartirla.

Utilizamos, entre otras cosas, KML service y queremos proponer la siguiente modificación al código en la Acción "toJS" de EGMapKMLService.php:

[color="#9932CC"]Hello, we were working with your extension to develop our application, and we were a great help. Thank you very much for sharing.

Used, among other things, KML service and we propose the following modification to the code in the Action "tojs" of EGMapKMLService.php:[/color]




/**

* @return string Create new control to display latlng and coordinates under mouse.

 */

	public function toJs( $map_js_name = 'map' )

	{

		/*new line--->>*/$return='var myKmlOptions = {preserveViewport: true, suppressInfoWindows: true};';//<<<<--------

		$return .= ' var '.$this->getJsName().'= new google.maps.KmlLayer(\''.$this->url.'\',myKmlOptions);'.PHP_EOL;

		$return .= $this->getJsName().'.setMap('.$map_js_name.');'.PHP_EOL;

		return  $return;

  	}







Agregando esa linea, el KML insertado se mostrará sin modificar el ZOOM ni la posición del mapa anterior.

Esperamos que sea útil.

[color="#9932CC"]Adding that line, inserted KML is displayed without modifying the ZOOM or previous map position.

We hope it is useful.

[/color]

Pablo Kogan,

Miguel Silva,

Marcelo Chacon

Really nice extension. I have been trying to achieve something and been unable to so thought i’d ask the pros.

I have a destination, but want to set the origin using geolocation so it gives directions / places from the users location.

Is this possible with EGMap?

I have done it straight in html/js, but I dont know how to do is using the extension as the js code is generated by the php class isnt it?

Hello,

How can i enabled and disabled kml layer with checkbox and this extension? Thanks!!

How can I open a map marker when you click link?

Hi guys

great widget, please don’t mind my silly question.

I just want to know how can I change where a marker label is displayed.I want to put it right below my marker, in center.

and also I want to cluster my markers, based on their value (I want to assign some value to them), not their count.

thanks in advance

How can i do, that infowindow autoopen, when page is load?

Can I reload EGMap with ajax without reload a page?

I had searching all articel but no one talk about it.

thanx…

apinx