2

I’m triying to load an EGMap on a partial view. This is my code:

This is the ajax button which calls the action loadmap:

echo CHtml::ajaxsubmitButton ("Press for geolocation",
                              CController::createUrl('organization/loadmap'),
                              array('update' => '#formMap'));

The action loadmap:

$this->renderPartial('_loadMap',array('model'=>$model),false,true);

And finally the partial view:

$address = $model->address . ", " . City::model()->giveLocation($model->cityID);

        echo $address;

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

        $gMap = new EGMap();
        $gMap->zoom = 5;
        $gMap->width = '100%';
        $gMap->height = 200;

        $mapTypeControlOptions = array(
            'position'=> EGMapControlPosition::RIGHT_TOP,
            'style'=>EGMap::MAPTYPECONTROL_STYLE_DEFAULT,
        );

        $gMap->mapTypeId = EGMap::TYPE_HYBRID;

        $gMap->mapTypeControlOptions= $mapTypeControlOptions;

        // Create geocoded address
        $geocoded_address = new EGMapGeocodedAddress($address);
        $geocoded_address->geocode($gMap->getGMapClient());

        // Center the map on geocoded address
        $gMap->setCenter($geocoded_address->getLat(), $geocoded_address->getLng());

        // Add marker on geocoded address
        $gMap->addMarker(
            new EGMapMarker($geocoded_address->getLat(), $geocoded_address->getLng())
        );

        $gMap->renderMap();

The website loads the div but not the map. Any suggestion???

The firebug says: google is not defined

Thank you so much!!!

Fran Hurtado
  • 154
  • 1
  • 10

1 Answers1

1

I figured out that it would not work in renderPartial you would have to use Iframe and you can update its src on event. This worked out for me

Afnan Bashir
  • 7,319
  • 20
  • 76
  • 138
  • can u provide me the src , how can we set marker on that by giving lattitude and longitude? – arun Aug 17 '12 at 06:02
  • what are you trying to accomplish? change coordinates depending on some dropdown value? if you take `Iframe` you cant do that because of browsers do not allow that – Afnan Bashir Aug 17 '12 at 07:12
  • yeah. i found another solution. – arun Aug 17 '12 at 13:40