<?php /** * EGmap3 Yii extension example view file. * * You can copy this file or its contents into your Yii * application for testing. * */ Yii::import('ext.jquery-gmap.*'); $gmap = new EGmap3Widget(); $gmap->setSize(600, 400); // base options $options = array('scaleControl' => true, 'streetViewControl' => false, 'zoom' => 1, 'center' => array(0, 0), 'mapTypeId' => EGmap3MapTypeId::HYBRID, 'mapTypeControlOptions' => array('style' => EGmap3MapTypeControlStyle::DROPDOWN_MENU, 'position' => EGmap3ControlPosition::TOP_CENTER), 'zoomControlOptions' => array('style' => EGmap3ZoomControlStyle::SMALL, 'position' => EGmap3ControlPosition::BOTTOM_CENTER)); $gmap->setOptions($options); $marker = new EGmap3Marker(array('title' => 'hello')); $marker->address = 'Jacksonville, FL'; //$marker->latLng = array(18.466465, -66.118292); //$marker->centerOnMap(); //$marker->setMapZoom(8); $gmap->add($marker); $polyOptions = array('fillColor' => 'yellow', 'strokeColor' => 'red'); $rectangleOptions = array_merge($polyOptions, array('bounds' => array(40, -72, 42, -76))); $rectangle = new EGmap3Rectangle($rectangleOptions); //$rectangle->centerOnMap(); $gmap->add($rectangle); $polygon = new EGmap3Polygon($polyOptions); $polygon->paths = array(array(18.466465, -66.118292), array(32.321384, -64.75736999999999), array(25.774252, -80.190262), array(25.774252, -80.190262)); //$polygon->centerOnMap(); $gmap->add($polygon); $polyline = new EGmap3Polyline(array('strokeColor' => 'orange'));
</li> </ul> </fieldset> <fieldset><legend>Property Location</legend> <ul> <li><span><label>Selected Location</label></span> <span id="location-map"> <?php Yii::import('ext.jquery-gmap.*'); ?> <?php $gmap = new EGmap3Widget(); $gmap->setSize('300', '200'); $gmap->setOptions(array('zoom' => 6, 'center' => $locationPosition, 'draggable' => false, 'panControl' => false, 'minZoom' => 8, 'width' => '300px', 'height' => '200px')); // add a marker $marker = new EGmap3Marker(array('title' => 'Updateable marker', 'draggable' => true)); $marker->latLng = $locationPosition; $marker->centerOnMap(); // $marker->address = '10 Downing St, Westminster, London SW1A 2, UK'; $js = "function(marker, event, data){\n var map = \$(this).gmap3('get'),\n \t\t infowindow = \$(this).gmap3({action:'get', name:'infowindow'}); \n\t\t if (infowindow){\n\t\t\t infowindow.open(map, marker);\n\t\t\t infowindow.setContent(data);\n\t\t } else {\n\t\t\t \$('#Property_latitude').val(marker.getPosition().lat());\n\t \t\t \t\$('#Property_longitude').val(marker.getPosition().lng());\n\t\t }\n\t\t}"; $marker->addEvent('click', $js); $marker->addEvent('drag', $js); $marker->addEvent('dragend', $js); $marker->addEvent('position_changed', $js); $gmap->add($marker); // tell the gmap to update the marker from the Address model fields. $gmap->updateMarkerAddressFromModel($model, array('address', 'address2', 'city', 'zip', 'state', 'country'), array()); $gmap->renderMap(); ?>