Commit 4cef9ce0 by Junaid Rahman pv

modified business module, map implemented

parent 07d481f7
......@@ -2,7 +2,6 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
//use common\widgets\GooglePlaceComplete\PlaceComplete;
/* @var $this yii\web\View */
/* @var $model common\models\Business */
......@@ -11,6 +10,11 @@ use yii\widgets\ActiveForm;
/* @var $districts array */
?>
<div class="row">
</div>
<div class="business-form">
<?php $form = ActiveForm::begin(); ?>
......@@ -18,12 +22,12 @@ use yii\widgets\ActiveForm;
<div class="row">
<div class="col-md-4">
<?= $form->field($model, 'category_id')->dropDownList($categories,['prompt' => ' ']) ?>
<?= $form->field($model, 'category_id')->dropDownList($categories, ['prompt' => ' ']) ?>
</div>
<div class="col-md-4">
<?= $form->field($model, 'district_id')->dropDownList($districts,['prompt' => ' '])?>
<?= $form->field($model, 'district_id')->dropDownList($districts, ['prompt' => ' ']) ?>
</div>
</div>
......@@ -123,19 +127,24 @@ use yii\widgets\ActiveForm;
</div>
<div class="row">
<div class="col-md-6">
Address:
<input id="searchTextField" type="text" size="50" style="text-align: left;width:357px;direction: ltr;">
<br>
</div>
</div>
<div class="row">
<div class="col-md-10">
<div id="myMap" style="height: 350px;width: 680px"></div>
<div id="map_canvas" style="height: 350px;width: 500px;margin: 0.6em;"></div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?php echo $form->field($model, 'latitude')->textInput([['maxlength' => true]]) ?>
<?= $form->field($model, 'latitude')->textInput(['maxlength' => true, 'class' => 'map-lat']) ?>
</div>
<div class="col-md-4">
<?php echo $form->field($model, 'longitude')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'longitude')->textInput(['maxlength' => true, 'class' => 'map-lon']) ?>
</div>
</div>
<div class="row">
......@@ -148,6 +157,112 @@ use yii\widgets\ActiveForm;
'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
<?php ActiveForm::end();
$a = 1; ?>
<script
src="http://maps.google.com/maps/api/js?key=AIzaSyBcXUZ8SohRQzKnY4iYaa5_B2ix0b_OY9g&libraries=places&region=uk&language=en&sensor=true"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>
$(function(){
createmap();
function createmap(){
var lat = $('.map-lat').val(),
lng = $('.map-lon').val(),
latlng = new google.maps.LatLng(lat, lng),
image = 'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png';
if (!lat && !lng) {
lat = 10.5113798;
lng = 76.1532094;
}
//zoomControl: true,
//zoomControlOptions: google.maps.ZoomControlStyle.LARGE,
var mapOptions = {
center: new google.maps.LatLng(lat, lng),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.TOP_RIGHT
},
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE,
position: google.maps.ControlPosition.TOP_left
}
},
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions),
marker = new google.maps.Marker({
position: latlng,
map: map,
draggable: true,
icon: image
});
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input, {
types: ["geocode"]
});
autocomplete.bindTo('bounds', map);
var infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(autocomplete, 'place_changed', function (event) {
infowindow.close();
var place = autocomplete.getPlace();
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
moveMarker(place.name, place.geometry.location);
$('.map-lat').val(place.geometry.location.lat());
$('.map-lon').val(place.geometry.location.lng());
});
google.maps.event.addListener(map, 'click', function (event) {
$('.map-lat').val(event.latLng.lat());
$('.map-lon').val(event.latLng.lng());
infowindow.close();
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
"latLng": event.latLng
}, function (results, status) {
console.log(results, status);
if (status == google.maps.GeocoderStatus.OK) {
console.log(results);
var lat = results[0].geometry.location.lat(),
lng = results[0].geometry.location.lng(),
placeName = results[0].address_components[0].long_name,
latlng = new google.maps.LatLng(lat, lng);
moveMarker(placeName, latlng);
$("#searchTextField").val(results[0].formatted_address);
}
});
});
google.maps.event.addListener(marker, 'click', function (event) {
$('.map-lat').val(event.latLng.lat());
$('.map-lon').val(event.latLng.lng());
infowindow.close();
});
google.maps.event.addListener(marker, 'dragend', function (event) {
$('.map-lat').val(event.latLng.lat());
$('.map-lon').val(event.latLng.lng());
infowindow.close();
});
$('.map-lat').bind('input', function () {
createmap();
infowindow.close();
});
$('.map-lon').bind('input', function () {
createmap();
infowindow.close();
});
function moveMarker(placeName, latlng) {
marker.setIcon(image);
marker.setPosition(latlng);
infowindow.setContent(placeName);
//infowindow.open(map, marker);
}
}
});
</script>
</div>
......@@ -57,7 +57,7 @@ $this->params['breadcrumbs'][] = $this->title;
// 'logo_base_url:url',
// 'logo_path',
// 'latitude',
// 'logitude',
// 'longitude',
[
'class' => \common\grid\EnumColumn::className(),
'attribute' => 'status',
......
......@@ -45,7 +45,7 @@ $this->params['breadcrumbs'][] = $this->title;
'logo_base_url:url',
'logo_path',
'latitude',
'logitude',
'longitude',
'status',
'created_at',
'updated_at',
......
......@@ -60,7 +60,6 @@
"codeception/verify": "^0.3.0"
},
"minimum-stability": "stable",
"opauth/openid": "dev-master",
"suggest": {
"trntv/yii2-debug-xhprof": "dev-master@dev"
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment