From 557ac29ed046e7f6e76ea81c3473970293d42af6 Mon Sep 17 00:00:00 2001 From: stes Date: Thu, 27 Jul 2017 16:00:09 +0300 Subject: [PATCH] stock map --- web/js/stock.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/web/js/stock.js b/web/js/stock.js index 8b0569b..75e2530 100644 --- a/web/js/stock.js +++ b/web/js/stock.js @@ -19,15 +19,32 @@ $(function() { $("#add-data").data('count', count); } ); - $(document).on( '#shoplang-2-address','blur', function () { + $(document).on('blur', '#shoplang-2-address', function () { var address = $("#shoplang-2-address").val() + " "+$("#select2-w2-container").text(); console.log(address); geocoder.geocode( { 'address': address}, function(results, status) { console.log(status); if (status == google.maps.GeocoderStatus.OK) { - //console.log(results[0].geometry.location.lat()+" "+results[0].geometry.location.lng()); + $("#lat").val(results[0].geometry.location.lat()); $("#lng").val(results[0].geometry.location.lng()); + start_position = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()); + settings = { + styles: styles, + zoom: 12, + scrollwheel: false, + center: start_position, + mapTypeControl: true, + mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, + navigationControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + scaleControl: true, + streetViewControl: true, + rotateControl: true, + zoomControl: true, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + map = new google.maps.Map(document.getElementById("map_canvas"), settings); var marker = AddMarker(); marker.setMap(map); } else { @@ -35,8 +52,17 @@ $(function() { } }); }); - - var start_position = new google.maps.LatLng('50.435', '30.60'); + var lat, lng; + if ($("#lat").val() !== "" && $("#lng").val() !== ""){ + lat = $("#lat").val(); + lng = $("#lng").val(); + }else{ + lat = '50.435'; + lng = '30.60'; + } + console.log(lat); + console.log(lng); + var start_position = new google.maps.LatLng(lat, lng); var styles = [ { stylers: [ -- libgit2 0.21.4