<!--КАРТА ДОСТАВКИ-->
<script>
const geojsonData =
//************************VVVVVVV
{
"type": "FeatureCollection",
"metadata": {
"name": "Ческыт карта",
"creator": "Yandex Map Constructor"
},
"features": [
{
"type": "Feature",
"id": 0,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
53.15946446687456,
56.84359760579417
],
[
53.12468857581339,
56.87176010745359
],
[
53.117135475227435,
56.8724181319242
],
[
53.10958237464153,
56.87359314670293
],
[
53.10245842749795,
56.87100806525005
],
[
53.09696526343546,
56.867858723575615
],
[
53.102286766121004,
56.86522623368216
],
[
53.102850589165215,
56.85832730807419
],
[
53.1031509965749,
56.85362509985653
],
[
53.10791459978534,
56.85266695217325
],
[
53.107710751900186,
56.852414185179065
],
[
53.10781804026081,
56.851191474120284
],
[
53.10196120271222,
56.85174253576883
],
[
53.1005666387877,
56.849469600813116
],
[
53.10236908324573,
56.84943432807705
],
[
53.10419298537583,
56.84903456806879
],
[
53.099450839837544,
56.848740624150906
],
[
53.0950520170531,
56.84878765533354
],
[
53.096768630822616,
56.84654185012606
],
[
53.102476371606315,
56.84470747951503
],
[
53.107351513316274,
56.84381231584397
],
[
53.1046907619735,
56.83971983477961
],
[
53.09991579779705,
56.83633668262968
],
[
53.0980704379948,
56.83151406744583
],
[
53.078661973563186,
56.82476135855116
],
[
53.066645677176474,
56.816736515904246
],
[
53.06630235442258,
56.81362966183357
],
[
53.07192426451781,
56.81285290790382
],
[
53.082352693167685,
56.81120519453964
],
[
53.10525756277926,
56.8079084461757
],
[
53.104313425206,
56.8057661208686
],
[
53.10680251517188,
56.80412986655013
],
[
53.10839038290866,
56.803317598560284
],
[
53.11540704169166,
56.80231695428788
],
[
53.123260549687295,
56.7998446593336
],
[
53.1290112058152,
56.795464763602745
],
[
53.13459020056648,
56.79348657788139
],
[
53.13776593604009,
56.79242679238918
],
[
53.13748698630261,
56.789047053414095
],
[
53.14027648367812,
56.78749250634318
],
[
53.14385991492199,
56.78649143799656
],
[
53.14746480383802,
56.78545500956592
],
[
53.15036158957411,
56.78398276066623
],
[
53.15319400229382,
56.783299617473524
],
[
53.15415959753929,
56.7834645152941
],
[
53.15471749701439,
56.780614037019106
],
[
53.15609078803001,
56.77986015516857
],
[
53.15875153937279,
56.77953032707669
],
[
53.160811475896196,
56.7796245639714
],
[
53.163257650517814,
56.78044912666382
],
[
53.16621880927026,
56.7806611541298
],
[
53.16866498389183,
56.780755388173
],
[
53.175402692937254,
56.78122655482454
],
[
53.179737142705285,
56.78169771553552
],
[
53.18351369299826,
56.78179194696484
],
[
53.18389993109641,
56.78285203417129
],
[
53.185015730046615,
56.7864561057342
],
[
53.18634838210605,
56.79072186191378
],
[
53.187507096400516,
56.793830622652486
],
[
53.18973869430092,
56.80105984595247
],
[
53.19149822341475,
56.80673392356975
],
[
53.192399445643744,
56.81024153192251
],
[
53.19304317580732,
56.811300811924575
],
[
53.19510311233078,
56.81106541896634
],
[
53.1973776255754,
56.81127727269555
],
[
53.20121854888474,
56.8123718311638
],
[
53.203750554194876,
56.81330159217252
],
[
53.20224851714652,
56.815655313937455
],
[
53.198557797542016,
56.82132717349913
],
[
53.19795698272271,
56.82276265268531
],
[
53.199802342524954,
56.82379804601042
],
[
53.199759427180744,
56.8249981250621
],
[
53.199029866328694,
56.82925691749255
],
[
53.19834322082086,
56.83259772923139
],
[
53.19864362823054,
56.833232920141846
],
[
53.20044607268853,
56.83365637473888
],
[
53.20121854888484,
56.83415039902541
],
[
53.20104688750789,
56.83504433112203
],
[
53.19808572875544,
56.83492670970489
],
[
53.19718450652645,
56.835632432643145
],
[
53.198471966853596,
56.83631461878888
],
[
53.19945901977106,
56.83746724978204
],
[
53.19937318908259,
56.83854927910888
],
[
53.196884099116765,
56.838878586150244
],
[
53.19559663878962,
56.83941958426176
],
[
53.19542497741267,
56.840242827197095
],
[
53.19598287688777,
56.84198333813447
],
[
53.19598287688777,
56.844358769235555
],
[
53.18915933715387,
56.84417062179641
],
[
53.1867131625323,
56.845464116264196
],
[
53.18182081328912,
56.84612260529865
],
[
53.17748636352105,
56.84753361406187
],
[
53.173454869096254,
56.84627865836859
],
[
53.17032204896685,
56.84380927484987
],
[
53.16345559388874,
56.84340945451354
],
[
53.15946446687456,
56.84359760579417
]
]
]
},
"properties": {
"description": "Доставка из кафе \"Ческыт\" (Клубная) 250 руб. Время доставки 1,5 часа.",
"fill": "#ed4543",
"fill-opacity": 0.6,
"stroke": "#ed4543",
"stroke-width": "5",
"stroke-opacity": 0.9
}
},
{
"type": "Feature",
"id": 1,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
53.19722087199313,
56.860042473621206
],
[
53.20022494608975,
56.84287733384509
],
[
53.24520022685141,
56.84689891807624
],
[
53.25301081950263,
56.84835692912103
],
[
53.25477615407121,
56.859247848383156
],
[
53.25349942258006,
56.86521865000434
],
[
53.25191155484323,
56.86559473145637
],
[
53.25135365536803,
56.86586503761746
],
[
53.250860128909295,
56.86618235108663
],
[
53.25139657071229,
56.86707551522781
],
[
53.254035864382956,
56.87159976768664
],
[
53.23987380078426,
56.87211679010344
],
[
53.22296515515437,
56.87216379178675
],
[
53.21326628735654,
56.87202278655882
],
[
53.20794478467099,
56.871740774501326
],
[
53.20811644604789,
56.86939059096381
],
[
53.201464567690984,
56.869367088379555
],
[
53.20234433224787,
56.860576081796914
],
[
53.19722087199313,
56.860042473621206
]
]
]
},
"properties": {
"description": "Доставка из кафе \"Ческыт\" (Удмуртская) 200 руб. Время доставки 1,5 часа.",
"fill": "#0e4779",
"fill-opacity": 0.6,
"stroke": "#0e4779",
"stroke-width": "5",
"stroke-opacity": 0.9
}
},
{
"type": "Feature",
"id": 2,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
53.209117849287175,
56.817522452929325
],
[
53.21016927522101,
56.816463349493795
],
[
53.21591993134892,
56.81699290496873
],
[
53.21774383347906,
56.81742831161884
],
[
53.221692045148984,
56.817393008566206
],
[
53.22295804780398,
56.81693406583518
],
[
53.22802205842405,
56.817663664442314
],
[
53.240767915662815,
56.81844031823836
],
[
53.247291047987034,
56.819499365567715
],
[
53.280292947706194,
56.82401762978507
],
[
53.28544278901479,
56.825782428153914
],
[
53.28308244508165,
56.82935883013066
],
[
53.298446138318916,
56.83086458101645
],
[
53.31441064637555,
56.83387590042936
],
[
53.31333776276961,
56.837945500494854
],
[
53.31067701142684,
56.839403861784405
],
[
53.30864926141159,
56.84012714077326
],
[
53.301289279874744,
56.84295543855506
],
[
53.30493708413493,
56.84805876773594
],
[
53.305838306363924,
56.85137438136212
],
[
53.30506583016766,
56.85798121409545
],
[
53.30369253915199,
56.86531554226374
],
[
53.30349942010289,
56.86625573632154
],
[
53.308928211149066,
56.86660830297797
],
[
53.31005625960579,
56.86528260175238
],
[
53.317008545372374,
56.86551765270133
],
[
53.32381062743407,
56.86604651189119
],
[
53.32110696074704,
56.87020660916816
],
[
53.319270848984196,
56.87428361253098
],
[
53.31230901195765,
56.87631517817735
],
[
53.3082535119271,
56.87610369371351
],
[
53.30681584789501,
56.88201305734519
],
[
53.31205151989208,
56.88321126320474
],
[
53.30834735347901,
56.889587740588816
],
[
53.310836443444835,
56.89973396389179
],
[
53.28281272365717,
56.894990009390746
],
[
53.261912951013045,
56.891349436099524
],
[
53.25998176052232,
56.89461422473561
],
[
53.25929511501454,
56.8952953315743
],
[
53.24024070217271,
56.89188967270135
],
[
53.229404577752526,
56.88965820990853
],
[
53.2267438264097,
56.88357385805331
],
[
53.231700548669245,
56.88236391664208
],
[
53.237322458764474,
56.880860245336464
],
[
53.23852408840305,
56.88043732681622
],
[
53.237118610879264,
56.88002027748164
],
[
53.238180765649204,
56.877312280118424
],
[
53.24206460430276,
56.87787621771419
],
[
53.244918474694586,
56.878780849766414
],
[
53.24910272075777,
56.878005452195275
],
[
53.25116265728123,
56.87793496070759
],
[
53.25775016262171,
56.8777587313821
],
[
53.25948823406338,
56.87783509751585
],
[
53.26035726978417,
56.8777587313821
],
[
53.26669801189534,
56.877012684744244
],
[
53.272416481515044,
56.876425235924145
],
[
53.28205097629651,
56.875297308237286
],
[
53.28243721439461,
56.87449833877186
],
[
53.27808130695433,
56.8717781892105
],
[
53.27645052387329,
56.87079113118319
],
[
53.275903353234234,
56.87004494493906
],
[
53.27564586116882,
56.86910484651775
],
[
53.27582825138182,
56.86828224093349
],
[
53.27608574344724,
56.867571260026644
],
[
53.276536354561706,
56.86680150507547
],
[
53.27712644054492,
56.86606111506801
],
[
53.277147898217024,
56.86565565716917
],
[
53.27743757679065,
56.86443925698482
],
[
53.2779954762657,
56.86234719081219
],
[
53.27857483341291,
56.85959676778478
],
[
53.27883232547833,
56.85780418194865
],
[
53.280033955116956,
56.85226719200641
],
[
53.28054893924784,
56.84756421905338
],
[
53.28093517734595,
56.8419669079388
],
[
53.28140724613258,
56.837662521550136
],
[
53.28179348423068,
56.834675032326416
],
[
53.279690632363014,
56.833263536859114
],
[
53.27866066410128,
56.83281655215762
],
[
53.27291000797337,
56.832063723686865
],
[
53.27033508731907,
56.831804935398175
],
[
53.2691334576804,
56.831816698541154
],
[
53.267481216927244,
56.83228722121846
],
[
53.261666187782915,
56.83376344757615
],
[
53.258994707604096,
56.8341045593035
],
[
53.24882377101958,
56.83552778489865
],
[
53.236120829125085,
56.83416337133264
],
[
53.21768868877473,
56.83254012465278
],
[
53.212195524712186,
56.831987263638084
],
[
53.20919145061552,
56.83186963257923
],
[
53.206659445305434,
56.83191668504728
],
[
53.2076464982228,
56.825681715849505
],
[
53.2082043976979,
56.82259913860517
],
[
53.20730317546891,
56.828834622962056
],
[
53.209117849287175,
56.817522452929325
]
]
]
},
"properties": {
"description": "Доставка из кафе \"Ческыт\" (Удмуртская) 300 руб. Время доставки 2 часа.",
"fill": "#ffd21e",
"fill-opacity": 0.6,
"stroke": "#ffd21e",
"stroke-width": "5",
"stroke-opacity": 0.9
}
},
{
"type": "Feature",
"id": 3,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
53.226453860322835,
56.88338344933197
],
[
53.22250564865291,
56.88166836635079
],
[
53.2170108321973,
56.88239314940277
],
[
53.214811420805056,
56.8822051939437
],
[
53.206206894285216,
56.88164132190241
],
[
53.20412550008965,
56.881018703284845
],
[
53.203224277860606,
56.87987916675573
],
[
53.19955501592826,
56.87912728851339
],
[
53.19824609792896,
56.88091297453089
],
[
53.196357822782446,
56.88084836237758
],
[
53.19350395239052,
56.880783750104655
],
[
53.1930747989481,
56.8815708372462
],
[
53.18725976980382,
56.88242839086063
],
[
53.18275365865875,
56.883990732273304
],
[
53.175157642728536,
56.88387326525838
],
[
53.174814319974644,
56.88323893705306
],
[
53.1777754787271,
56.88246363234496
],
[
53.17768964803862,
56.880278595836096
],
[
53.16859159506011,
56.87943274082085
],
[
53.16863451040432,
56.87837539502674
],
[
53.1695142749612,
56.8767188262272
],
[
53.16429475051379,
56.87893349558419
],
[
53.161333591761334,
56.87812872988304
],
[
53.15088601963725,
56.869072371704576
],
[
53.1507143582603,
56.86660449829526
],
[
53.15165849583356,
56.864230484803656
],
[
53.16103549854955,
56.858623921778474
],
[
53.174746951033676,
56.85693120863519
],
[
53.1859049405356,
56.8583182986855
],
[
53.19062562840183,
56.857424924566935
],
[
53.19397302525239,
56.85441550676078
],
[
53.19463821308802,
56.852687332778004
],
[
53.19485278980918,
56.849848015827185
],
[
53.1961348857182,
56.846438198255605
],
[
53.19613488571815,
56.84447447211696
],
[
53.1955769862429,
56.84028209983871
],
[
53.19561990158706,
56.839508840820606
],
[
53.19692345516823,
56.83893550154703
],
[
53.19956274883885,
56.83854444970111
],
[
53.199482282568354,
56.837415374740154
],
[
53.19866957323677,
56.836373008260274
],
[
53.197400888372684,
56.83564818617869
],
[
53.19809826271658,
56.83501891746958
],
[
53.20116670982961,
56.83505567409653
],
[
53.201330119242066,
56.83406417925894
],
[
53.200450354685124,
56.8336333776655
],
[
53.1987592219012,
56.83324227020077
],
[
53.19852318750778,
56.83296069968727
],
[
53.19993406263412,
56.823504437552714
],
[
53.19795995679913,
56.8227514211491
],
[
53.20386175914184,
56.81346310449856
],
[
53.20722880231729,
56.8167939157452
],
[
53.20866646634928,
56.81761765816265
],
[
53.206426333242504,
56.83206112730256
],
[
53.211522530370736,
56.832067008811826
],
[
53.248783778005496,
56.83568397500312
],
[
53.259208297174816,
56.83421522941509
],
[
53.26216945592727,
56.8338623562059
],
[
53.26757678930129,
56.83245082998069
],
[
53.26946506444775,
56.83195678318092
],
[
53.27847728673775,
56.83289781904301
],
[
53.27950725499947,
56.83333304010952
],
[
53.28122386876904,
56.834862154938094
],
[
53.28055868093326,
56.84224807283665
],
[
53.27862749044248,
56.856204403054264
],
[
53.277640437524916,
56.863045446045795
],
[
53.276953792017125,
56.86554881277415
],
[
53.276910876672865,
56.86600715747518
],
[
53.27579507772266,
56.86771121009047
],
[
53.27554831449324,
56.86923303945321
],
[
53.2759345525914,
56.8704316566548
],
[
53.27614912931261,
56.870854688802744
],
[
53.28023145143324,
56.87316365460947
],
[
53.28236648980907,
56.87450901651201
],
[
53.282044624727234,
56.875199303412614
],
[
53.267879135427286,
56.87678544607024
],
[
53.25942481261234,
56.87779584250149
],
[
53.25813735228519,
56.877643109901406
],
[
53.249189503011515,
56.877948574445206
],
[
53.24660385352111,
56.878430263426736
],
[
53.24516618948912,
56.87867110558803
],
[
53.24462974768612,
56.878600615360625
],
[
53.242215759572666,
56.877813465407016
],
[
53.238170988378165,
56.877208406000186
],
[
53.23694790106739,
56.88002801643156
],
[
53.23838556509933,
56.880436254820665
],
[
53.2366930912109,
56.88095462301688
],
[
53.23294336300806,
56.88200602187901
],
[
53.23143596154168,
56.8823672498402
],
[
53.226453860322835,
56.88338344933197
]
],
[
[
53.20798272591536,
56.87179327400055
],
[
53.22240228157942,
56.87226329223992
],
[
53.24162835579819,
56.87207528565305
],
[
53.25415963631574,
56.87151126019757
],
[
53.25098390084213,
56.86643464668521
],
[
53.25083369713729,
56.866199601507674
],
[
53.25191730957933,
56.86560610587151
],
[
53.253462261971904,
56.865206519324666
],
[
53.25425619584032,
56.8615571556069
],
[
53.25469607811874,
56.85926510191854
],
[
53.25306529503769,
56.84828479720519
],
[
53.245190329369905,
56.84689733363838
],
[
53.222273535546634,
56.844863077588506
],
[
53.20020431977204,
56.842863989521746
],
[
53.19971079331331,
56.845662682772236
],
[
53.19886117721068,
56.8505619834976
],
[
53.19719820762138,
56.86006649063447
],
[
53.20236950660203,
56.860595427207805
],
[
53.20188670897935,
56.865073456171324
],
[
53.201457555536884,
56.86939818047619
],
[
53.208087976221734,
56.86940993176037
],
[
53.20798272591536,
56.87179327400055
]
]
]
},
"properties": {
"description": "Доставка из кафе \"Ческыт\" (Удмуртская) 250 руб. Время доставки 2 часа.",
"fill": "#f371d1",
"fill-opacity": 0.6,
"stroke": "#f371d1",
"stroke-width": "5",
"stroke-opacity": 0.9
}
}
]
}
//************************AAAAAAA
;
</script> <!--КОД ДЛЯ ДОСТАВКИ ПО ЗОНАМ-->
<link href="https://cdn.jsdelivr.net/npm/suggestions-jquery@22.6.0/dist/css/suggestions.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/suggestions-jquery@22.6.0/dist/js/jquery.suggestions.min.js"></script>
<script src="https://api-maps.yandex.ru/2.1.79/?apikey=9fc14d7f-2173-4103-b7bb-bf30073dad94&lang=ru_RU" type="text/javascript"></script>
<script>
t_onReady(function() {
setTimeout(function() {
t_onFuncLoad('tcart__init',function() {
createSuggestionAndMap();
});
},200);
});
function createSuggestionAndMap(){
//Позиция доставки в списке, для которой мы будем изменять цену
let deliveryPosition = 0;
let addressName = 'адрес'; //Имя поля с адресом
let yandexSearch = null;
let delivInp = $('.t706 input[name="'+addressName+'"]');
let inputID = delivInp.attr('id');
delivInp.closest('.t-input-group').addClass('innpy-group');
$('.innpy-group').append('<div id="map"></div>');
$('.innpy-group .t-input-block').after('<div class="delivery-text t-text"></div>');
const resultDiv = document.querySelector('.delivery-text');
function removeMetro(suggestions) {
return suggestions.filter(function(suggestion) {
return suggestion.data.street_type_full !== "метро";
});
};
function createSuggestions($form){
$form.find('[name="'+addressName+'"]').suggestions({
token: "dde74e92aa80b9137d858c6536d9d23dbc99da93",
type: "ADDRESS",
constraints: {
locations: {
kladr_id: "1800000100000" //Ижевск
}
},
onSelectNothing: function() {
$('.t706 [name="'+addressName+'"]').val('');
$('.address-group').addClass('js-error-control-box');
$('.address-group .t-input-error').text('Обязательно выберите адрес из списка');
changeDeliveryPrice(0);
resultDiv.style.display = 'none';
},
onSelect: function(suggestion) {
if (yandexSearch) yandexSearch(suggestion.value);
},
restrict_value: true,
onSuggestionsFetch: removeMetro,
});
};
$('.t706 .t-input-group').addClass('t-text');
let $form = $(".t706 form");
createSuggestions($form);
$('.t706 [name="'+addressName+'"]').closest('.t-input-group').addClass('address-group');
$('.t706 [name="'+addressName+'"]').attr('autocomplete', 'new-address');
$('.t706').on('input' , '[name="'+addressName+'"]', function(){
$('.address-group').removeClass('js-error-control-box');
$('.address-group .t-input-error').text('Обязательное поле');
});
let cur = $('.t706').attr('data-project-currency');
const deliveryElement = document.querySelectorAll('.t-radio__wrapper-delivery .t-radio_delivery')[deliveryPosition];
function changeDeliveryPrice(em){
deliveryElement.setAttribute('data-delivery-price', em);
tcart__updateDelivery();
};
let map;
let geoObjects = [];
ymaps.ready(init);
function init() {
map = new ymaps.Map('map', {
center: [56.845096, 53.188089],
zoom: 11
});
displayGeoJSONonMap(geojsonData);
};
function displayGeoJSONonMap(data) {
if (!data || !data.features) return;
data.features.forEach(feature => {
if (feature.geometry && feature.geometry.coordinates) {
const coordinates = feature.geometry.coordinates;
let ymapsObject;
if (feature.geometry.type === 'Polygon') {
const paths = coordinates[0].map(coord => [coord[1], coord[0]]);
ymapsObject = new ymaps.Polygon([paths]);
} else if (feature.geometry.type === 'MultiPolygon') {
const polygons = coordinates.map(polygon =>
polygon[0].map(coord => [coord[1], coord[0]])
);
ymapsObject = new ymaps.Polygon(polygons);
}
if (ymapsObject) {
// Применяем оригинальные стили из GeoJSON
applyOriginalStyles(ymapsObject, feature.properties);
// Добавляем только description в балун
if (feature.properties && feature.properties.description) {
ymapsObject.properties.set({
balloonContent: feature.properties.description,
hintContent: feature.properties.description
});
}
map.geoObjects.add(ymapsObject);
geoObjects.push(ymapsObject);
}
}
});
}
function applyOriginalStyles(ymapsObject, properties) {
if (!properties) return;
const options = {
// Базовые настройки
opacity: 0.6,
strokeWidth: 2
};
// Применяем стили из свойств
if (properties.fill) {
options.fillColor = properties.fill;
}
if (properties.stroke) {
options.strokeColor = properties.stroke;
}
if (properties['fill-opacity']) {
options.opacity = parseFloat(properties['fill-opacity']);
}
if (properties['stroke-width']) {
options.strokeWidth = parseFloat(properties['stroke-width']);
}
if (properties['stroke-opacity']) {
options.strokeOpacity = parseFloat(properties['stroke-opacity']);
}
ymapsObject.options.set(options);
}
yandexSearch = function(adress) {
checkAddress(adress);
};
async function checkAddress(em) {
const address = em;
if (!address) {
showResult('Введите адрес для проверки', 'error');
return;
}
try {
// Геокодирование адреса
const geocoderResult = await ymaps.geocode(address);
const firstGeoObject = geocoderResult.geoObjects.get(0);
if (!firstGeoObject) {
showResult('Адрес не найден', 'error');
return;
}
const coordinates = firstGeoObject.geometry.getCoordinates();
// Отображение метки адреса на карте
showAddressMarker(coordinates, address);
// Проверка попадания в зоны
checkPointInZones(coordinates, address);
} catch (error) {
console.error('Ошибка геокодирования:', error);
showResult('Ошибка при обработке адреса', 'error');
}
}
function showAddressMarker(coordinates, address) {
// Удаляем предыдущую метку
map.geoObjects.each(geoObject => {
if (geoObject.options.get('preset') === 'islands#blueCircleDotIcon') {
map.geoObjects.remove(geoObject);
}
});
// Добавляем новую метку
const addressMarker = new ymaps.Placemark(
coordinates,
{
balloonContent: address,
iconCaption: address
},
{
preset: 'islands#blueCircleDotIcon'
}
);
map.geoObjects.add(addressMarker);
map.setCenter(coordinates, 15);
}
function checkPointInZones(coordinates, address) {
if (!geojsonData || !geojsonData.features) {
showResult('Данные зон не загружены', 'error');
return;
}
let foundZones = [];
geojsonData.features.forEach((feature) => {
if (isPointInFeature(coordinates, feature)) {
// Добавляем только description зоны
const zoneName = feature.properties && feature.properties.description
? feature.properties.description
: 'Неизвестная зона';
foundZones.push(zoneName);
}
});
if (foundZones.length > 0) {
let zoneText = foundZones.join(', ');
zoneText = zoneText.split('руб')[0].trim();
zoneText = zoneText.replace(/\D/g, '');
showResult(`Стоимость доставки: <strong>${zoneText} ${cur}</strong>`, 'success');
changeDeliveryPrice(zoneText);
} else {
showResult(`Адрес "${address}" не попадает ни в одну из зон. Введите другой адрес или выберите самовывоз`, 'error');
}
}
function isPointInFeature(point, feature) {
if (!feature.geometry || !feature.geometry.coordinates) return false;
const [lng, lat] = point;
const testPoint = [lat, lng];
if (feature.geometry.type === 'Polygon') {
return isPointInPolygon(testPoint, feature.geometry.coordinates);
} else if (feature.geometry.type === 'MultiPolygon') {
return feature.geometry.coordinates.some(polygon =>
isPointInPolygon(testPoint, polygon)
);
};
return false;
};
function isPointInPolygon(point, polygon) {
const [x, y] = point;
let inside = false;
for (let i = 0, j = polygon[0].length - 1; i < polygon[0].length; j = i++) {
const [xi, yi] = polygon[0][i];
const [xj, yj] = polygon[0][j];
const intersect = ((yi > y) !== (yj > y)) &&
(x < (xj - xi) * (y - yi) / (yj - yi) + xi);
if (intersect) inside = !inside;
};
return inside;
};
function showResult(message, type) {
resultDiv.classList.remove('success', 'error');
resultDiv.style.display = 'inline-block';
resultDiv.innerHTML = message;
resultDiv.classList.add('result', type);
if(type=="error"){
delivInp.value = '';
changeDeliveryPrice(0);
};
};
};
</script>
<style>
/* Общие стили для карты */
#map {
width: 100%;
height: 400px;
margin-top: 20px;
display: none;
}
/* Стили для результатов */
.result {
margin: 0 0 10px 0;
border-radius: 5px;
padding: 3px 15px;
width: auto;
}
.success {
background-color: #d4edda;
padding: 3px 15px;
}
.error {
background-color: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
/* Стили для элементов формы */
.t706 .delivery-text .t-input-block,
.t706 .innpy-group .t-input-block {
margin-bottom: 0;
}
.t706 .innpy-group .t-input-block {
position: relative;
margin-bottom: 10px;
}
.t706 .t-input-group.t-input-group_ta.delivery-text {
margin-bottom: 20px;
}
.t706__cartwin-totalamount-wrap {
margin-bottom: 20px;
}
/* Стили для доставки */
.delivery-text .t-input-subtitle {
font-size: 18px;
font-weight: 400;
display: none;
}
.delivery-text.show-txt .t-input-subtitle {
display: block;
}
.wrap-dlv {
display: grid;
grid-template-columns: 200px 1fr;
width: fit-content;
font-size: 18px;
}
.dlv-adress, .dlv-price, .dlv-free {
margin-right: 15px;
font-weight: 600;
}
/* Скрытие элементов */
textarea[name="delivery-info"] {
height: 0 !important;
border: none !important;
padding: 0 !important;
opacity: 0;
}
textarea[name="delivery-info"]+div {
display: none !important;
}
.t-input-group.t-input-group_dl {
/*display: none;*/
}
/* Стили для Яндекс карт */
ymaps[class$="-map-copyrights-promo"],
ymaps[class*="-controls__control_toolbar"],
ymaps[class*="-search__layout"],
.suggestions-promo {
display: none !important;
}
ymaps[class*="-controls__control_toolbar"] {
margin-left: 0 !important;
}
ymaps[class$="-controls__toolbar"] {
margin-top: 1px !important;
}
ymaps[class$="-searchbox__normal-layout"] {
margin-top: -51px;
margin-left: 41px;
width: calc(100% - 41px);
}
/* Поле ввода адреса */
input[name="adressinp"] {
background: url(https://static.tildacdn.com/tild6330-3038-4630-b636-396539356535/3586361-location-map.svg) no-repeat 99% center / 50px 70%;
}
/* Стили поисковой строки */
input[class*="-searchbox-input__input"] {
height: 50px;
font-family: 'Montserrat', Arial, sans-serif;
font-size: 15px;
}
ymaps[class$="-searchbox-button-text"] {
line-height: 30px;
padding: 10px 28px;
}
ymaps[class*="-searchbox-button"] {
height: 50px;
background-color: #fff;
overflow: hidden;
font-family: 'Montserrat', Arial, sans-serif;
font-size: 14px;
}
ymaps[class*="-float-button"] {
height: 50px;
width: 41px;
background-position: 2px 6px;
transform: translate(0px, -1px);
}
ymaps[class*="_focused"] {
box-shadow: 0 0 0 1px #fff !important;
}
/* Стили для подсказок адреса */
.suggestions-wrapper .suggestions-suggestions {
position: absolute;
z-index: 99;
border: none;
width: 90%;
border-radius: 14px;
box-shadow: 0 0 10px 0 #c8c8c8;
padding: 10px;
}
.suggestions-suggestions strong {
font-weight: 400;
color: #96c291;
}
.suggestions-suggestion {
padding: 7px 4px;
overflow: hidden;
cursor: pointer;
}
.suggestions-suggestion:hover {
background: #f7f7f7;
border-radius: 4px;
}
.suggestions-suggestions.suggestions-mobile .suggestions-suggestion {
border-bottom: 1px solid #ddd;
}
.deliv-wrp .t-input-subtitle.t-descr {
font-size: 13px;
}
/* Адаптивные стили */
@media screen and (max-width: 532px) {
.wrap-dlv {
grid-template-columns: 205px 1fr;
}
ymaps[class*="-searchbox__panel-layout"] {
transform: none;
}
ymaps[class*="-searchbox__fold-button-cell"] {
display: none;
background-color: #fff;
}
input[class*="-searchbox-input__input"] {
height: 30px;
font-size: 12px;
}
ymaps[class*="-searchbox__button-cell"],
ymaps[class*="-searchbox__input-cell"] {
display: block;
}
ymaps[class*="-searchbox-button"] {
height: 32px;
font-size: 12px;
line-height: 23px;
margin-top: 5px;
width: 100%;
text-align: center;
padding: 0;
}
ymaps[class*="-searchbox-button"]:hover {
background: #fff;
}
ymaps[class*="-searchbox__button-cell"] {
background: #fff;
padding-left: 0 !important;
}
ymaps[class*="--searchbox__panel-layout"] {
padding-left: 0;
}
ymaps[class*="-float-button"] {
height: 30px;
width: 70px;
text-align: center;
padding: 0 !important;
line-height: 30px;
}
ymaps[class*="-controls__control_toolbar"] {
width: 40px;
}
ymaps[class*="-button-icon_icon_geolocation"] {
width: 30px;
background-position: 2px -2px;
}
}
@media screen and (max-width: 479px) {
.t706 .t-form__inputsbox_flex .t-input-group.t-input-group_inonerow {
width: calc((100% - 15px) / 2);
}
}
</style>