Author: Antonio Ramirez (amigo.cobos@gmail.com)
Inheritance: extends dosamigos\google\maps\ObjectAbstract
Ejemplo n.º 1
3
 public function actionViewAdvert($id)
 {
     $model = Advert::findOne($id);
     $data = ['name', 'email', 'text'];
     $model_feedback = new DynamicModel($data);
     $model_feedback->addRule('name', 'required');
     $model_feedback->addRule('email', 'required');
     $model_feedback->addRule('text', 'required');
     $model_feedback->addRule('email', 'email');
     if (Yii::$app->request->isPost) {
         if ($model_feedback->load(Yii::$app->request->post()) && $model_feedback->validate()) {
             Yii::$app->common->sendMail('Subject Advert', $model_feedback->text);
         }
     }
     $user = $model->user;
     $images = Common::getImageAdvert($model, false);
     $current_user = ['email' => '', 'username' => ''];
     if (!Yii::$app->user->isGuest) {
         $current_user['email'] = Yii::$app->user->identity->email;
         $current_user['username'] = Yii::$app->user->identity->username;
     }
     $coords = str_replace(['(', ')'], '', $model->location);
     $coords = explode(',', $coords);
     $coord = new LatLng(['lat' => $coords[0], 'lng' => $coords[1]]);
     $map = new Map(['center' => $coord, 'zoom' => 15]);
     $marker = new Marker(['position' => $coord, 'title' => Common::getTitleAdvert($model)]);
     $map->addOverlay($marker);
     return $this->render('view_advert', ['model' => $model, 'model_feedback' => $model_feedback, 'user' => $user, 'images' => $images, 'current_user' => $current_user, 'map' => $map]);
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $coord = new LatLng(['lat' => $this->model->latitude, 'lng' => $this->model->longitude]);
     $this->mapOptions['center'] = $coord;
     $map = new Map($this->mapOptions);
     $marker = new Marker(array_merge($this->markerOptions, ['position' => $coord]));
     $map->addOverlay($marker);
     echo Html::tag('div', $map->display(), ['class' => 'map-canvas']);
 }
Ejemplo n.º 3
0
 public function GenerateMap($first = '', $second = '')
 {
     if ($first == '') {
         $first = 'mannheim';
     }
     $address1 = $first;
     $prepAddr1 = str_replace(' ', '+', $address1);
     $geocode1 = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $prepAddr1 . '&sensor=false');
     $output1 = json_decode($geocode1);
     $latitude1 = $output1->results[0]->geometry->location->lat;
     $longitude1 = $output1->results[0]->geometry->location->lng;
     if ($second == '') {
         $second = 'berlin';
     }
     $address2 = $second;
     $prepAddr2 = str_replace(' ', '+', $address2);
     $geocode2 = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $prepAddr2 . '&sensor=false');
     $output2 = json_decode($geocode2);
     $latitude2 = $output2->results[0]->geometry->location->lat;
     $longitude2 = $output2->results[0]->geometry->location->lng;
     $coord = new LatLng(['lat' => $latitude1, 'lng' => $longitude1]);
     $map = new Map(['center' => $coord, 'zoom' => 14]);
     // lets use the directions renderer
     $home = new LatLng(['lat' => $latitude1, 'lng' => $longitude1]);
     $school = new LatLng(['lat' => $latitude2, 'lng' => $longitude2]);
     $directionsRequest = new DirectionsRequest(['origin' => $home, 'destination' => $school, 'travelMode' => TravelMode::DRIVING]);
     // Lets configure the polyline that renders the direction
     $polylineOptions = new PolylineOptions(['strokeColor' => '#FFAA00', 'draggable' => true]);
     // Now the renderer
     $directionsRenderer = new DirectionsRenderer(['map' => $map->getName(), 'polylineOptions' => $polylineOptions]);
     // Finally the directions service
     $directionsService = new DirectionsService(['directionsRenderer' => $directionsRenderer, 'directionsRequest' => $directionsRequest]);
     // Thats it, append the resulting script to the map
     $map->appendScript($directionsService->getJs());
     return $map;
 }
Ejemplo n.º 4
0
use dosamigos\google\maps\Map;
use dosamigos\google\maps\overlays\Circle;
$model = common\models\User::findOne(1);
$model2 = common\models\User::findOne(22);
$coord = new LatLng(['lat' => $model->location->lat, 'lng' => $model->location->lng]);
$map = new Map(['center' => $coord, 'zoom' => 10]);
$map->width = '100%';
$map->height = '431';
// Lets add a marker now
$marker = new Marker(['position' => $coord, 'title' => 'My Home Town']);
// Lets add a marker now
$circle = new Circle(['center' => $coord, 'radius' => 3000]);
// Add marker to the map
$map->addOverlay($marker);
$map->addOverlay($circle);
$map2 = new Map(['center' => $coord, 'zoom' => 14]);
$map2->width = '100%';
$map2->height = '176';
// Lets add a marker now
$marker2 = new Marker(['position' => $coord, 'title' => 'My Home Town']);
// Add marker to the map
$map2->addOverlay($marker2);
echo distance($model->location->lat, $model->location->lng, $model2->location->lat, $model2->location->lng);
?>

<?php 
echo Yii::$app->request->url == '/index' ? 'yes' : 'no';
?>

<div class="site-index">
<div class="body-content">
Ejemplo n.º 5
0
/* @var $this yii\web\View */
$this->title = 'Map Display';
//"Url::to(['test/jsonrecord', 'id'=>20])"
use dosamigos\google\maps\LatLng;
use dosamigos\google\maps\services\DirectionsWayPoint;
use dosamigos\google\maps\services\TravelMode;
use dosamigos\google\maps\overlays\PolylineOptions;
use dosamigos\google\maps\services\DirectionsRenderer;
use dosamigos\google\maps\services\DirectionsService;
use dosamigos\google\maps\overlays\InfoWindow;
use dosamigos\google\maps\overlays\Marker;
use dosamigos\google\maps\Map;
use dosamigos\google\maps\services\DirectionsRequest;
use dosamigos\google\maps\overlays\Polygon;
use dosamigos\google\maps\layers\BicyclingLayer;
$map = new Map(['center' => new LatLng(['lat' => 39.720089311812096, 'lng' => 2.91165944519042]), 'zoom' => 1]);
$map->containerOptions = ["id" => "main_map", "style" => "width:100%; height:500px;padding:20px;"];
$map->width = "100%";
$map->height = "500px";
foreach ($reports as $report) {
    $coord = new LatLng(['lat' => $report->lat, 'lng' => $report->long]);
    // Lets add a marker now
    ${$report->idmain} = new Marker(['position' => $coord]);
    // Provide a shared InfoWindow to the marker
    ${$report->idmain}->attachInfoWindow(new InfoWindow(['content' => '<p>' . $report->problem_prose . '</p>']));
    // Add marker to the map
    $map->addOverlay(${$report->idmain});
}
/*
$js = "$(checkbox).onChange(function() {";
Ejemplo n.º 6
0
 public function map($width = 400, $height = 420, $lw = null, $m = true)
 {
     $coord = new LatLng(['lat' => $this->lat, 'lng' => $this->lng]);
     $map = new Map(['center' => $coord, 'zoom' => $this->mapZoom($lw)]);
     $map->width = $width;
     $map->height = $height;
     if ($m) {
         // Lets add a marker now
         $marker = new Marker(['position' => $coord, 'title' => 'Mesto gde vršimo uslugu']);
         // Add marker to the map
         $map->addOverlay($marker);
     }
     if ($lw) {
         // Lets add a marker now
         $circle = new Circle(['center' => $coord, 'radius' => $lw * 1000, 'strokeColor' => '#2196F3', 'strokeWeight' => 1, 'fillOpacity' => 0.08]);
         $map->addOverlay($circle);
     }
     return $map;
 }
Ejemplo n.º 7
0
                <a href="http://stat.vgg.ru" target="_blank" class="no-decoration color-w stat">статистика</a-->

<?php 
$this->beginBody();
?>
    <!-- main body, remove div for height compability -->
    <?php 
echo $content;
?>

    <div id="map">
        <?php 
$coord = new LatLng(['lat' => 48.751678, 'lng' => 44.478525]);
$marker = new Marker(['position' => $coord, 'title' => 'My Home Town', 'icon' => '/img/map-pin.png']);
$marker->attachInfoWindow(new InfoWindow(['content' => '<div>' . '<h2>Унико</h2>' . '<b>Адрес</b>: г.Волгоград, ул. Землячки 30а, 5 подъезд, код домофона 42<br>' . '<b>Унико</b> &ndash; интернет &dash; провайдер и оператор связи в Волгоградской области.' . '</div>']));
$map = new Map(['width' => '100%', 'height' => '100%', 'center' => $coord, 'zoom' => 17, 'scrollwheel' => false, 'panControl' => false, 'mapTypeControl' => false, 'streetViewControl' => false, 'styles' => '[{"stylers":[{"saturation":-100},{"gamma":1}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]},{"featureType":"poi.business","elementType":"labels.text","stylers":[{"visibility":"off"}]},{"featureType":"poi.business","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"poi.place_of_worship","elementType":"labels.text","stylers":[{"visibility":"off"}]},{"featureType":"poi.place_of_worship","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"geometry","stylers":[{"visibility":"simplified"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"saturation":50},{"gamma":0},{"hue":"#50a5d1"}]},{"featureType":"administrative.neighborhood","elementType":"labels.text.fill","stylers":[{"color":"#333333"}]},{"featureType":"road.local","elementType":"labels.text","stylers":[{"weight":0.5},{"color":"#333333"}]},{"featureType":"transit.station","elementType":"labels.icon","stylers":[{"gamma":1},{"saturation":50}]}]']);
$map->addOverlay($marker);
echo $map->display();
?>
    </div>
    <footer class="main-footer">
        <div>
            <div class="row">
                <div class="col-lg-5">
                    <h3>О нас</h3>
                    <p>
                        Компания УНИКО является <strong>интернет-провайдером в Волгоградской области</strong>. На базе собственной волоконно-оптической и
                        широкополосной беспроводной сети мы предлагаем интегрированные телекоммуникационные решения для разных категорий
                        клиентов.
                    </p>
                </div>
Ejemplo n.º 8
0
<?php

use dosamigos\google\maps\LatLng;
use dosamigos\google\maps\services\DirectionsWayPoint;
use dosamigos\google\maps\services\TravelMode;
use dosamigos\google\maps\overlays\PolylineOptions;
use dosamigos\google\maps\services\DirectionsRenderer;
use dosamigos\google\maps\services\DirectionsService;
use dosamigos\google\maps\overlays\InfoWindow;
use dosamigos\google\maps\overlays\Marker;
use dosamigos\google\maps\Map;
use dosamigos\google\maps\services\DirectionsRequest;
use dosamigos\google\maps\overlays\Polygon;
use dosamigos\google\maps\layers\BicyclingLayer;
$coord = new LatLng(['lat' => 16, 'lng' => 100]);
$map = new Map(['center' => $coord, 'zoom' => 8]);
// lets use the directions renderer
$home = new LatLng(['lat' => 15.9, 'lng' => 99.91180171966555]);
$school = new LatLng(['lat' => 39.719456079114956, 'lng' => 2.8979293346405166]);
$santo_domingo = new LatLng(['lat' => 39.72118906848983, 'lng' => 2.907628202438368]);
// setup just one waypoint (Google allows a max of 8)
$waypoints = [new DirectionsWayPoint(['location' => $santo_domingo])];
$directionsRequest = new DirectionsRequest(['origin' => $home, 'destination' => $school, 'waypoints' => $waypoints, 'travelMode' => TravelMode::DRIVING]);
// Lets configure the polyline that renders the direction
$polylineOptions = new PolylineOptions(['strokeColor' => '#FFAA00', 'draggable' => true]);
// Now the renderer
$directionsRenderer = new DirectionsRenderer(['map' => $map->getName(), 'polylineOptions' => $polylineOptions]);
// Finally the directions service
$directionsService = new DirectionsService(['directionsRenderer' => $directionsRenderer, 'directionsRequest' => $directionsRequest]);
// Thats it, append the resulting script to the map
$map->appendScript($directionsService->getJs());
Ejemplo n.º 9
0
/* @var $this yii\web\View */
/* @var $model frontend\models\Orders */
use yii\helpers\Html;
use yii\helpers\Url;
use kartik\widgets\ActiveForm;
use kartik\tabs\TabsX;
use dosamigos\google\maps\LatLng;
use dosamigos\google\maps\overlays\InfoWindow;
use dosamigos\google\maps\overlays\Marker;
use dosamigos\google\maps\Map;
use dosamigos\google\maps\overlays\Circle;
/* items */
/* maps */
$coord = new LatLng(['lat' => $model->loc->lat, 'lng' => $model->loc->lng]);
$map = new Map(['center' => $coord, 'zoom' => $model->loc_within ? 10 : 15]);
$map->width = '100%';
$map->height = '420';
// Lets add a marker now
$marker = new Marker(['position' => $coord, 'title' => 'My Home Town']);
// Lets add a marker now
$circle = new Circle(['center' => $coord, 'radius' => $model->loc_within ? $model->loc_within * 1000 : 500, 'strokeColor' => '#2196F3', 'strokeWeight' => 1, 'fillOpacity' => 0.08]);
// Add marker to the map
//$map->addOverlay($marker);
$map->addOverlay($circle);
/*$map->appendScript("google.maps.event.addDomListener(mapShowTrigger, 'click', function() {
      $(this).closest('.hidden-content-container').find('div.hidden-content').toggleClass('hidden');
      initialize();
  });");*/
?>
<div class="card_container record-full" id="service-location" style="float:none;">
Ejemplo n.º 10
0
 public function run()
 {
     MapAsset::register($this->getView());
     return $this->map->display();
 }
Ejemplo n.º 11
0
use yii\helpers\Html;
use dosamigos\google\maps\LatLng;
use dosamigos\google\maps\services\DirectionsWayPoint;
use dosamigos\google\maps\services\TravelMode;
use dosamigos\google\maps\overlays\PolylineOptions;
use dosamigos\google\maps\services\DirectionsRenderer;
use dosamigos\google\maps\services\DirectionsService;
use dosamigos\google\maps\overlays\InfoWindow;
use dosamigos\google\maps\overlays\Marker;
use dosamigos\google\maps\Map;
use dosamigos\google\maps\services\DirectionsRequest;
use dosamigos\google\maps\overlays\Polygon;
use dosamigos\google\maps\layers\BicyclingLayer;
use yii\bootstrap\ActiveForm;
$coord = new LatLng(['lat' => 39.720089311812096, 'lng' => 2.91165944519042]);
$map = new Map(['center' => $coord, 'zoom' => 14]);
// lets use the directions renderer
$home = new LatLng(['lat' => 39.720991014764536, 'lng' => 2.911801719665541]);
$school = new LatLng(['lat' => 39.719456079114956, 'lng' => 2.8979293346405166]);
$directionsRequest = new DirectionsRequest(['origin' => $home, 'destination' => $school, 'travelMode' => TravelMode::DRIVING]);
// Lets configure the polyline that renders the direction
$polylineOptions = new PolylineOptions(['strokeColor' => '#FFAA00', 'draggable' => true]);
// Now the renderer
$directionsRenderer = new DirectionsRenderer(['map' => $map->getName(), 'polylineOptions' => $polylineOptions]);
// Finally the directions service
$directionsService = new DirectionsService(['directionsRenderer' => $directionsRenderer, 'directionsRequest' => $directionsRequest]);
// Thats it, append the resulting script to the map
$map->appendScript($directionsService->getJs());
$this->title = 'About';
$this->params['breadcrumbs'][] = $this->title;
?>
Ejemplo n.º 12
0
<?php 
use dosamigos\google\maps\LatLng;
use dosamigos\google\maps\services\DirectionsWayPoint;
use dosamigos\google\maps\services\TravelMode;
use dosamigos\google\maps\overlays\PolylineOptions;
use dosamigos\google\maps\services\DirectionsRenderer;
use dosamigos\google\maps\services\DirectionsService;
use dosamigos\google\maps\overlays\InfoWindow;
use dosamigos\google\maps\overlays\Marker;
use dosamigos\google\maps\Map;
use dosamigos\google\maps\services\DirectionsRequest;
use dosamigos\google\maps\overlays\Polygon;
use dosamigos\google\maps\layers\BicyclingLayer;
$coord = new LatLng(['lat' => 16, 'lng' => 100]);
$map = new Map(['center' => $coord, 'zoom' => 8]);
// Lets add a marker now
$marker = new Marker(['position' => new LatLng(['lat' => 16, 'lng' => 100]), 'title' => 'My Home Town', 'icon' => 'home.png']);
// Provide a shared InfoWindow to the marker
$marker->attachInfoWindow(new InfoWindow(['content' => '<p>This is my super cool content</p>']));
$map->addOverlay($marker);
$marker = new Marker(['position' => new LatLng(['lat' => 15.97, 'lng' => 99.87]), 'title' => 'My Home Town', 'icon' => 'home.png']);
// Provide a shared InfoWindow to the marker
$marker->attachInfoWindow(new InfoWindow(['content' => '<p>This is my super cool content</p>']));
$map->addOverlay($marker);
$marker = new Marker(['position' => new LatLng(['lat' => 16.1, 'lng' => 100.09]), 'title' => 'My Home Town', 'icon' => 'home.png']);
// Provide a shared InfoWindow to the marker
$marker->attachInfoWindow(new InfoWindow(['content' => '<p>This is my super cool content</p>']));
// Add marker to the map
$map->addOverlay($marker);
// Display the map -finally :)