Commit 557ac29ed046e7f6e76ea81c3473970293d42af6
1 parent
031b4e2b
stock map
Showing
1 changed file
with
30 additions
and
4 deletions
Show diff stats
web/js/stock.js
| @@ -19,15 +19,32 @@ $(function() { | @@ -19,15 +19,32 @@ $(function() { | ||
| 19 | $("#add-data").data('count', count); | 19 | $("#add-data").data('count', count); |
| 20 | } | 20 | } |
| 21 | ); | 21 | ); |
| 22 | - $(document).on( '#shoplang-2-address','blur', function () { | 22 | + $(document).on('blur', '#shoplang-2-address', function () { |
| 23 | var address = $("#shoplang-2-address").val() + " "+$("#select2-w2-container").text(); | 23 | var address = $("#shoplang-2-address").val() + " "+$("#select2-w2-container").text(); |
| 24 | console.log(address); | 24 | console.log(address); |
| 25 | geocoder.geocode( { 'address': address}, function(results, status) { | 25 | geocoder.geocode( { 'address': address}, function(results, status) { |
| 26 | console.log(status); | 26 | console.log(status); |
| 27 | if (status == google.maps.GeocoderStatus.OK) { | 27 | if (status == google.maps.GeocoderStatus.OK) { |
| 28 | - //console.log(results[0].geometry.location.lat()+" "+results[0].geometry.location.lng()); | 28 | + |
| 29 | $("#lat").val(results[0].geometry.location.lat()); | 29 | $("#lat").val(results[0].geometry.location.lat()); |
| 30 | $("#lng").val(results[0].geometry.location.lng()); | 30 | $("#lng").val(results[0].geometry.location.lng()); |
| 31 | + start_position = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()); | ||
| 32 | + settings = { | ||
| 33 | + styles: styles, | ||
| 34 | + zoom: 12, | ||
| 35 | + scrollwheel: false, | ||
| 36 | + center: start_position, | ||
| 37 | + mapTypeControl: true, | ||
| 38 | + mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, | ||
| 39 | + navigationControl: false, | ||
| 40 | + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, | ||
| 41 | + scaleControl: true, | ||
| 42 | + streetViewControl: true, | ||
| 43 | + rotateControl: true, | ||
| 44 | + zoomControl: true, | ||
| 45 | + mapTypeId: google.maps.MapTypeId.ROADMAP | ||
| 46 | + }; | ||
| 47 | + map = new google.maps.Map(document.getElementById("map_canvas"), settings); | ||
| 31 | var marker = AddMarker(); | 48 | var marker = AddMarker(); |
| 32 | marker.setMap(map); | 49 | marker.setMap(map); |
| 33 | } else { | 50 | } else { |
| @@ -35,8 +52,17 @@ $(function() { | @@ -35,8 +52,17 @@ $(function() { | ||
| 35 | } | 52 | } |
| 36 | }); | 53 | }); |
| 37 | }); | 54 | }); |
| 38 | - | ||
| 39 | - var start_position = new google.maps.LatLng('50.435', '30.60'); | 55 | + var lat, lng; |
| 56 | + if ($("#lat").val() !== "" && $("#lng").val() !== ""){ | ||
| 57 | + lat = $("#lat").val(); | ||
| 58 | + lng = $("#lng").val(); | ||
| 59 | + }else{ | ||
| 60 | + lat = '50.435'; | ||
| 61 | + lng = '30.60'; | ||
| 62 | + } | ||
| 63 | + console.log(lat); | ||
| 64 | + console.log(lng); | ||
| 65 | + var start_position = new google.maps.LatLng(lat, lng); | ||
| 40 | var styles = [ | 66 | var styles = [ |
| 41 | { | 67 | { |
| 42 | stylers: [ | 68 | stylers: [ |