Beispiel #1
0
/**
 * 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.*');
// init widget
$gmap = new EGmap3Widget();
$gmap->setSize(600, 400);
// base options for map
$options = array('zoom' => 12, 'center' => array('41.850033', '-87.650052'), 'mapTypeId' => EGmap3MapTypeId::ROADMAP, 'mapTypeControlOptions' => array('mapTypeIds' => array(EGmap3MapTypeId::ROADMAP, 'style1', 'style2')));
$gmap->setOptions($options);
// init the styled map, specify ID to match mapTypeIds above
$styledMap1 = new EGmap3StyledMap('style1', array('name' => 'Style 1'));
// add a map style
$styledMap1->addStyle(array('featureType' => 'road.highway', 'elementType' => 'geometry', 'stylers' => array('hue' => '#ff0022', 'saturation' => 60, 'lightness' => -20)));
// add and set the map
$gmap->add($styledMap1);
// Styled Map 2 ...
$styledMap2 = new EGmap3StyledMap('style2', array('name' => 'Style 2'));
$styledMap2->addStyle(array('featureType' => 'road.highway', 'elementType' => 'geometry', 'stylers' => array('hue' => '#ff0022', 'saturation' => 60, 'lightness' => -20)));
$styledMap2->addStyle(array('featureType' => 'road.arterial', 'elementType' => 'geometry', 'stylers' => array(array('saturation' => 30, 'lightness' => -40), array('hue' => '#2200ff', 'visibility' => 'simplified'))));
$styledMap2->addStyle(array('featureType' => 'road.local', 'elementType' => 'all', 'stylers' => array('hue' => '#f6ff00', 'saturation' => 50, 'gamma' => 0.7, 'visibility' => 'simplified')));
// specify to only add the map and not activate it
$styledMap2->doNotSet();
$gmap->add($styledMap2);
// render the map
$gmap->renderMap();
Beispiel #2
0
 * 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'));
$polyline->path = array(array(25.774252, -80.190262), array(23.1168, -82.3885569), array(18.539269, -72.33640800000001));
//$polyline->centerOnMap();
$gmap->add($polyline);
$circleOptions = array_merge($polyOptions, array('radius' => 100000));
$circle = new EGmap3Circle($circleOptions);
Beispiel #3
0
<?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' => 9, 'center' => array(0, 0), 'mapTypeId' => EGmap3MapTypeId::HYBRID, 'mapTypeControlOptions' => array('style' => EGmap3MapTypeControlStyle::DROPDOWN_MENU, 'position' => EGmap3ControlPosition::TOP_CENTER));
$gmap->setOptions($options);
// marker with custom icon
$marker = new EGmap3Marker(array('title' => 'hello', 'icon' => array('url' => 'http://google-maps-icons.googlecode.com/files/dolphins.png', 'anchor' => array('x' => 1, 'y' => 36))));
// set marker position by address
$marker->address = 'Jacksonville, FL';
// data associated with the marker
$marker->data = 'test data !';
// add a Javascript event on marker click
$js = "function(marker, event, data){\n        var map = \$(this).gmap3('get'),\n        infowindow = \$(this).gmap3({action:'get', name:'infowindow'});\n        if (infowindow){\n            infowindow.open(map, marker);\n            infowindow.setContent(data);\n        } else {\n            \$(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data}});\n        }\n}";
$marker->addEvent('click', $js);
// center the map on the marker
$marker->centerOnMap();
$gmap->add($marker);
$gmap->renderMap();