Display Leaflet marker using latitude and longitude from XAMPP database using Laravel framework

I need help with this problem since I tried quite a few tutorials and videos, but I still can’t implement them.
The homepage of my website including the Leaflet map
I intend to use the coordinates from my table in my xampp database, create a marker and display it on the map.

Here is my homepage HTML code:

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>HelpThePoor</title>

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href={{url('css/main.css')}}>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
          integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
          crossorigin=""/>
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"
            integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
            crossorigin=""></script>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">



    <!-- Styles -->
    <style>
        /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}a{background-color:transparent}[hidden]{display:none}html{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5}*,:after,:before{box-sizing:border-box;border:0 solid #e2e8f0}a{color:inherit;text-decoration:inherit}svg,video{display:block;vertical-align:middle}video{max-width:100%;height:auto}.bg-white{--bg-opacity:1;background-color:#fff;background-color:rgba(255,255,255,var(--bg-opacity))}.bg-gray-100{--bg-opacity:1;background-color:#f7fafc;background-color:rgba(247,250,252,var(--bg-opacity))}.border-gray-200{--border-opacity:1;border-color:#edf2f7;border-color:rgba(237,242,247,var(--border-opacity))}.border-t{border-top-width:1px}.flex{display:flex}.grid{display:grid}.hidden{display:none}.items-center{align-items:center}.justify-center{justify-content:center}.font-semibold{font-weight:600}.h-5{height:1.25rem}.h-8{height:2rem}.h-16{height:4rem}.text-sm{font-size:.875rem}.text-lg{font-size:1.125rem}.leading-7{line-height:1.75rem}.mx-auto{margin-left:auto;margin-right:auto}.ml-1{margin-left:.25rem}.mt-2{margin-top:.5rem}.mr-2{margin-right:.5rem}.ml-2{margin-left:.5rem}.mt-4{margin-top:1rem}.ml-4{margin-left:1rem}.mt-8{margin-top:2rem}.ml-12{margin-left:3rem}.-mt-px{margin-top:-1px}.max-w-6xl{max-width:72rem}.min-h-screen{min-height:100vh}.overflow-hidden{overflow:hidden}.p-6{padding:1.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.pt-8{padding-top:2rem}.fixed{position:fixed}.relative{position:relative}.top-0{top:0}.right-0{right:0}.shadow{box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px 0 rgba(0,0,0,.06)}.text-center{text-align:center}.text-gray-200{--text-opacity:1;color:#edf2f7;color:rgba(237,242,247,var(--text-opacity))}.text-gray-300{--text-opacity:1;color:#e2e8f0;color:rgba(226,232,240,var(--text-opacity))}.text-gray-400{--text-opacity:1;color:#cbd5e0;color:rgba(203,213,224,var(--text-opacity))}.text-gray-500{--text-opacity:1;color:#a0aec0;color:rgba(160,174,192,var(--text-opacity))}.text-gray-600{--text-opacity:1;color:#718096;color:rgba(113,128,150,var(--text-opacity))}.text-gray-700{--text-opacity:1;color:#4a5568;color:rgba(74,85,104,var(--text-opacity))}.text-gray-900{--text-opacity:1;color:#1a202c;color:rgba(26,32,44,var(--text-opacity))}.underline{text-decoration:underline}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.w-5{width:1.25rem}.w-8{width:2rem}.w-auto{width:auto}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}@media (min-width:640px){.sm:rounded-lg{border-radius:.5rem}.sm:block{display:block}.sm:items-center{align-items:center}.sm:justify-start{justify-content:flex-start}.sm:justify-between{justify-content:space-between}.sm:h-20{height:5rem}.sm:ml-0{margin-left:0}.sm:px-6{padding-left:1.5rem;padding-right:1.5rem}.sm:pt-0{padding-top:0}.sm:text-left{text-align:left}.sm:text-right{text-align:right}}@media (min-width:768px){.md:border-t-0{border-top-width:0}.md:border-l{border-left-width:1px}.md:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:1024px){.lg:px-8{padding-left:2rem;padding-right:2rem}}@media (prefers-color-scheme:dark){.dark:bg-gray-800{--bg-opacity:1;background-color:#2d3748;background-color:rgba(45,55,72,var(--bg-opacity))}.dark:bg-gray-900{--bg-opacity:1;background-color:#1a202c;background-color:rgba(26,32,44,var(--bg-opacity))}.dark:border-gray-700{--border-opacity:1;border-color:#4a5568;border-color:rgba(74,85,104,var(--border-opacity))}.dark:text-white{--text-opacity:1;color:#fff;color:rgba(255,255,255,var(--text-opacity))}.dark:text-gray-400{--text-opacity:1;color:#cbd5e0;color:rgba(203,213,224,var(--text-opacity))}.dark:text-gray-500{--tw-text-opacity:1;color:#6b7280;color:rgba(107,114,128,var(--tw-text-opacity))}}
    </style>

    <style>
        body {
            font-family: 'Nunito', sans-serif;
        }
    </style>
</head>
<body>
    <div class="square">
        <div class="text-center">
            <a class="btn btn-secondary" href="/" role="button">Kembali ke Menu Utama</a>
            <a class="btn btn-secondary" href="#" role="button">Profil</a>
        </div>
        <br>
        <div class=" ">
            <div class="text-center">
                <h2>SOS Berhampiran</h2>
            </div>
            <div class="beneflist">
                <h3>Perlu Bantuan</h3>
                @foreach($beneficiary as $key => $data)
                    <div class="helpsquare">
                        <b style="font-size: 25px">{{$data->name}}</b><br>
                        {{$data->help_needed}}<br>
                        Jenis Bantuan: <b style="font-size: 20px">{{$data->help_type}}</b>
                    </div>
                @endforeach
            </div>
            <div class="beneflist">
                <h3>Mahu Membantu</h3>
                @foreach($donor as $key => $data)
                    <div class="helpsquare">
                        <b style="font-size: 25px">{{$data->name}}</b><br>
                        {{$data->help_offered}}<br>
                        Jenis Bantuan: <b style="font-size: 20px">{{$data->help_type}}</b><br>
                        <a href=" " type="buttons" class="btn btn-success">Lihat Bantuan</a>
                    </div>
                @endforeach
            </div>
        </div>
    </div>


    <div id="map">
        <div class="btn-group" style="z-index: 1001; margin: 0;position: absolute;top: 92%; left: 40%; -ms-transform: translateY(-50%);transform: translateY(-50%);"> <!-- Use 401 to be between map and controls -->
            <a class="btn btn-DANGER btn-lg btn-block" href="benef_form" role="button" style="color: white">SAYA PERLU BANTUAN!</a>
        </div>
    </div>

    <script
        src="{{url('js/map.js')}}">
    </script>

</body>
</html>

and here’s the database table ‘Beneficiary’

and here’s the current map.js

var map = L.map('map').setView([1.465036, 830.428012], 15);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
    attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
    maxZoom: 18,
    id: 'mapbox/streets-v11',
    tileSize: 512,
    zoomOffset: -1,
    accessToken: 'pk.eyJ1IjoiZGFuaWVscmFjaGV2YXNraSIsImEiOiJjbDFlZzBpN2wwcjE1M2ZuNHF3NXRvbGh5In0.U44yx8ueWFpYviMcI1U1Sw'
}).addTo(map);

//var marker = L.marker([1.469607, 830.42104]).addTo(map);
//marker.bindPopup("<b>Saya memerlukan</b><br>makanan").openPopup();

//var marker = L.marker([1.469607, 830.42104]).addTo(map);

function onMapClick(e) {
    alert("You clicked the map at " + e.latlng);
}
map.on('click', onMapClick);


Why does subtracting from this variable inside an Interval go below and above 0? [duplicate]

I can’t figure it out and i feel like this is messing with my code in a larger scope. Shouldn’t it just be dead 0? What am i missing?

var opacity = 1;
function FadeOut()
{

    fadeOutTimer = setInterval(() => {

        console.log(opacity);
        if (opacity <= 0)
        {
            opacity = 1;
            clearTimeout(fadeOutTimer);
            return;
        }

        opacity = (opacity <= 0) ? 0 : opacity - 0.1;
    }, 15);
}
<button onclick="FadeOut()" type="button">
Test
</button>

how do I reset a variable during a for cycle with if in it?

I’m a designer and I’ve been asked to do a very tedious task of importing a bunch of images and “group” them into the right categories and order.
most of the work is done, but i’m now in a dead end:

the question:
how do i reset a certain var if only one of the 3 statements is true?

j=1;
for (i=1; i<PhotoCount; i++) {
if (PhNOW!==PhPRE){
j==0
*create new folder*
*insert photo*
*move photo by j*
j++
} else {
*insert photo*
*move photo by j*
};
};

please bare with me if i mean move photo i just mean “shift” since i’m using AE scripts, and by “create folder” i mean create composition, while with “move photo” i mean move it my 1 second inside the comp

My VS CODE terminal starting directory becomes mysteriously long

My vscode terminal directory turns into a very very long combination of alphabets as soon as I type something in it. Like “xe1x84x82xe1x85xb3….”

this is how it looks when terminal is opened.
above is how it looks when terminal is opened.
enter image description here
above is how it turns into as soon as I type something in it.
enter image description here
above is what I get when I click ‘split terminal’ icon.

I used parcel to to configure this react project. Below is my package.json file

{
  "name": "vanilla-react",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "dev": "parcel public/index.html",
    "format": "prettier --write "src/**/*.{js,jsx}"",
    "format:check": "prettier --check "src/**/*.{js,jsx}"",
    "lint": "eslint "src/**/*.{js,jsx}" --quiet",
    "test": "jest",
    "test:watch": "jest --watch"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/preset-env": "^7.16.11",
    "@babel/preset-react": "^7.16.7",
    "@parcel/transformer-sass": "^2.5.0",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^12.1.3",
    "@testing-library/user-event": "^14.1.1",
    "babel-jest": "^28.0.1",
    "eslint": "^8.8.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-react": "^7.28.0",
    "eslint-plugin-react-hooks": "^4.5.0",
    "eslint-plugin-react-redux": "^4.0.0",
    "jest": "^27.5.1",
    "parcel": "^2.5.0",
    "prettier": "^2.6.2"
  },
  "dependencies": {
    "@reduxjs/toolkit": "^1.8.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-redux": "^8.0.1",
    "sass": "^1.51.0"
  },
  "browsersList": [
    "last 2 Chrome versions"
  ]
}

webpack 5 has a bug with react-router-dom routes

I’m trying with this config:

const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');

module.exports = merge(common, {
  mode: 'development',
  devtool: 'inline-source-map',
  output: {
    publicPath: '/'
  },
  devServer: {
    historyApiFallback: true,
    host: 'localhost',
    port: 3000,
    open: true,
  }
});

but historyApiFallback: true and publicPath: '/' don’t work and I get this error when open http://localhost:3000/14/51/31 in new tap or browser:

Cannot GET /14/51/31

and I’ve also this route in react-router-dom:

<Routes>
  <Route path="/:id/:category/:day" element={<Home />} />
  <Route path="/" element={<Home />} />
  <Route path="*" element={<NotFound />} />
</Routes>

It’s really strange… I think webpack has a bug!

"webpack": "^5.72.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.8.1",
"webpack-merge": "^5.8.0"

Regex pattern to Quantify more than one pattern [duplicate]

I want a regex pattern to quantify the pattern to a maximum length.

Regex : A number of letters followed by a number of hyphen (Order is important)

Quantify : Quantify it so that the whole regex limits to a certain length.

^[a-zA-Z0-9]+-{1,5}$

This regex here quantifies only hyphen to be between 1 to 5.

What I want is a ” pattern of letters followed by hyphen ” should be within 1 to 5

Positive Examples :

aa—

aaa–

a—-

aaaa-

Thanks in Advance

How can i bind to an input type file field that is created dynamically without an ID. Using jquery or javascript

So i’m using a joomla component (rsformspro) that produces dynamic input(file type) fields into a html form.

I have a listener which checks the file selected is landscape and below a certain filesize. When the file doesn’t meet the requirements. The file value is cleared(value =”). This works.

i also have an add file button. The script won’t fire on this button after a new input field has been added to the dom.

i have used jquery on function with change. Which works, as far as my script runs. but the resetting of value doesn’t work. i know i’m 99% of the way. just need the last part to reset the current input field field.
html below:

<div class="formBody" style="background-size: cover;">
                        <div class="rsfp-field-multiple-plus" style="background-size: cover;"><input type="file" name="form[image_upload_gallery][]" id="image_upload_gallery" data-rsfp-skip-ajax="true" class="rsform-upload-box" data-rsfp-minfiles="1" data-rsfp-maxfiles="20" data-rsfp-exts="[&quot;jpeg&quot;,&quot;jpg&quot;,&quot;png&quot;,&quot;gif&quot;,&quot;zip&quot;]"></div><button type="button" class="rsfp-field-multiple-plus-button" data-rsfp-maxfiles="20" data-rsfp-formid="4" onclick="RSFormPro.addMoreFiles(this);">Add another file</button>
                        <span class="formValidation"><span id="component47" class="formNoError">Invalid Input</span></span>
                        <p class="formDescription"></p>
                    <div class="rsfp-field-multiple-plus" style="background-size: cover;"><input type="file" name="form[image_upload_gallery][]" id="image_upload_gallery" data-rsfp-skip-ajax="true" class="rsform-upload-box" data-rsfp-minfiles="1" data-rsfp-maxfiles="20" data-rsfp-exts="[&quot;jpeg&quot;,&quot;jpg&quot;,&quot;png&quot;,&quot;gif&quot;,&quot;zip&quot;]"></div></div>

image of input field “Image upload Gallery”

Below is the jquery/javascript:

/*testing second image capture for the gallery field */ 
    var file_holder2 = jQuery(".formBody input:file").on('change',function (e) {
        var file, img;
        var widescreen = 16/9; 
        var standard = 4/3;
        
        console.log('image upscript script is active value of file is: '+jQuery('input[type=file]').val());
            if ((file = this.files[0])) {
                //alert('filesize is'+file.size);
                img = new Image();
                img.onload = function () {
                 var userRatio = this.width / this.height;
                 if(userRatio == widescreen && this.width > 600 && file.size < 1002400)//make sure image is 16/9, width less than 600 px & filesize less than 1mb
                 {
                    //all is ok and it can be uploaded.
                 }else{
                    alert("Please make sure your image is:n 1: Landscape (16:9 ratio).n 1024px x 768px is recommended (jpeg or PNG)n 2: No more than 1mb in size.n 3: Width must be 600px minimum.nn Please try again with another image filename is :"+this.value);
                     //jQuery(this).closest('div').remove();
                     //jQuery(this).hide();
                    //file.value='';
                     file_holder2.val('');
                     //file_holder2.value = '';
                     //jQuery(this).val('');
                    //this.files[0].value='';
                     //this.value=null;
                 }                          
                };
                img.src = _URL.createObjectURL(file);
        }
    }); 

This is inside a doc ready function.

The above script works for the 1st file field. But when a second is added. The script doesn’t fire.

When i add a second parameter ‘rsform-upload-box’ to the on change function like below:

var file_holder2 = jQuery(".formBody input:file").on('change','rsform-upload-box',function (e) {

Then the script doesn’t fire.

So just need to know what i need to make any newly added input value set to null.

How add multiple remoteSearch function in tributejs

If you used “tributejs” you know that you can pass remoteSearch function as values for use fetch data from outside, I need to append second remoteSearch function and show the list based on first user selected item.

this is a part of tributejs document:

{
  //..other config options
  // function retrieving an array of objects
  values: function (text, cb) {
    remoteSearch(text, users => cb(users));
  },
  lookup: 'name',
  fillAttr: 'name'
}

Drawn SVG doesnt show up in Browser [duplicate]

i’m creating a competition table dynamically with jquery and want to stroke connection lines between the single competition layers. I’m creating them with jquery as mentioned with the svg namespace e.g. Function for creating SVG Element with Line Tag as Child

It all works properly up to adding the elements to the DOM seeing in the inspector
DOM Tree Structure of SVG Element with Lines

But at the site directly the lines are not showing up.
They havo to be in the red rectangle

I’ve ended up testing several hours with this but not finding the Solution.

Thanks for help 🙂

Highcharts Issue in range selector buttonafter calling setExtremes in case of YTD button click

We have a highchart where we have implemented range selector , with buttons like 1d, 7d, 1m, 6m, 1y, YTD and ALL.

In our case we have data starting from Jan 1, 2020 till May 30, 2022 (future). Therefore, when we click on YTD button the chart is displayed ranging from Jan 1, 2022 till May 30, 2022. Ideally, in case of YTD we should have got data in the chart ranging from Jan 1 2022 till April 28,2022 (today).
I was able to fix this issue using the following piece of code –

fHighchartsOptions.xAxis.events = {
                setExtremes: function(e) {
                    if (e.trigger == "rangeSelectorButton") {

                        if (e.rangeSelectorButton.text == "YTD") {
                            var c = this;
                            setTimeout(function() {
                                var ytdExtremes = c.chart.rangeSelector.getYTDExtremes(new Date().getTime(), new Date(new Date().getFullYear(), 0, 1).getTime(), Highcharts.useUTC);
                                c.chart.xAxis[0].setExtremes(ytdExtremes.min, ytdExtremes.max);
                            }, 1);

                        }
                    }
                }
            };

The problem happens after this when I click on other buttons say 6m, the chart now shows data from Oct 28, 2021 till Apr 28, 2021 (6 months data).
Whereas when I click on ALL button and then I click on 6m now the chart shows data Nov 30, 2021 till May 30, 2022 (6 months data)

Here as you can see there is a discrepancy in the two result. My question here is, what can I change in the code so that after setExtremes is called on click of YTD button, what fields in chart I have to reset so that after I click 6m I get the result in the chart ranging from Nov 30,2021 till May 30, 2022.

Thanks in advance

JSON data formetter in a particular way

I am using javascript.I have a json data set. I am trying to convert in a particular way. Can someone write the function so that I can convert it.

Given Json data:

{
   "members":[
      {
         "value":"view",
         "code":"reservations"
      },
      {
         "value":"view",
         "code":"dashboard"
      }
   ]
}

Trying to convert in:

{
  "members": [
    {
      "view_reservation": true,
      "edit_reservation": true,
      "create_reservation": true,
      "delete_reservation": true
    },
    {
      "view_dashboard": true,
      "edit_dashboard": true,
      "create_dashboard": true,
      "delete_dashboard": true
    }
  ]
}

Can someone write a function in javascript to convert it…

I’m working with reactjs and cannot seem to prevent this error when trying to display JSON data (either from file or server):

I want to open one accordion at a time when I open other accordion second one should get closed. I am trying but I don’t know where I am going wrong.

const [courses, setCourses] = useState([]);
const [city,setCity]= useState([]);
const [countries, setCountries] = useState([]);
const [filteredCourses, setFilteredCourses] = useState([]);
const [categories, setCategories] = useState([]);
const [filteredcity, setFilteredCity] = useState([]);

const onClickButton = (chosenCategory) => {
    setFilteredCourses(courses.filter(course => course.coursecategory === chosenCategory)
)}

useState(() => {
    Axios
    .get("http://localhost:3100/courses")
    .then((response) => {
        
        setCourses(response.data);
        setFilteredCourses(response.data);
        setCategories(_.uniqBy(response.data.map(course => course.coursecategory)));    
    })
    .catch((error) => {
        console.log(error);
    });
}, []);
    
useEffect(()=>{
     fetch('http://localhost:3100/allcourses')
     .then((res)=>res.json())
     .then((results)=>setCourses(results));
    
},[]);
    
useState(() => {
    Axios
    .get("http://localhost:3100/cities")
    .then((response) => {
        setCity(response.data);
        setFilteredCity(response.data);
        setCountries(_.uniqBy(response.data.map(city => city.country)));    
    })
    .catch((error) => {
        console.log(error);
    });
}, []);

This is the accordion code:

{categories.map((category,index)=>(  
    <>
        <Accordion key={index}>
            <Card>

            <Accordion.Toggle as={Card.Header} eventKey='0' type="button"  onClick={() => onClickButton(category)} >
            
            <ul id={id.categorylist}  onClick={() => onClickButton(category)}> {category} <FaChevronDown style={{marginLeft:"100%"}}></FaChevronDown>  </ul> 
            </Accordion.Toggle>
            <Accordion.Collapse eventKey='0' onClick={() => onClickButton(category)}>
                <Card.Body>
                
                <div>
                    <div> 
                    {filteredCourses.map((course,index) => ( 
                        <a href={`/course/${course.course_slug}`} as={Link}  key={index}> {course.coursename}</a>   
                        ))}   
                    </div>
                </div>
                </Card.Body>
            </Accordion.Collapse>
            </Card>
        </Accordion>
    </>
))}

All data are coming dynamically based on the categories I choose but
when I open two accordion at a time it display second accordion data
which I have opened recently, I want to open one accordion panel at a
time when one panel open other should get closed. I tried all solution
but not getting proper solution for this when I use my code.