Google Maps Javascript api zoom issue with marker

I’ve a simple map with an svg file as marker icon. When the map is loaded no problem but, if i try to zoom in or out, the marker changes position (visually) and this is a problem.
The marker must not change position but remain fixed on the reference point.
How can I solve this problem ?

<style type="text/css">
    body { font: normal 10pt Helvetica, Arial; }
    #map { width: 100%; height: 100%; border: 0px; padding: 0px; }
</style>
<script src="https://maps.google.com/maps/api/js?libraries=geometry&key=AIzaSyBpL5_1SzkA3Q6LATyd19-8g5F_Zq_6w70" type="text/javascript"></script>
<script type="text/javascript">
    var icon = {
        url: "https://www.aisilbagno.it/wp-content/uploads/2015/04/google-maps-marker-for-residencelamontagne-hi.png", // url
        scaledSize: new google.maps.Size(50, 50), // scaled size
        origin: new google.maps.Point(0,0), // origin
        anchor: new google.maps.Point(0, 0), // anchor
    };
    var icon2 = {
        url: "https://cdn-icons-png.flaticon.com/512/1119/1119071.png", // url
        scaledSize: new google.maps.Size(50, 50), // scaled size
        origin: new google.maps.Point(0,0), // origin
        anchor: new google.maps.Point(0, 0), // anchor
    };
    var center = null;
    var map = null;
    var currentPopup;
    var bounds = new google.maps.LatLngBounds();
    function addMarker(icon, lat, lng, info) {
        var pt = new google.maps.LatLng(lat, lng);
        bounds.extend(pt);
        var marker = new google.maps.Marker({
            position: pt,
            icon: icon,
            map: map
        });
        var popup = new google.maps.InfoWindow({
            content: info,
            maxWidth: 350
        });
        google.maps.event.addListener(marker, "click", function() {
            if (currentPopup != null) {
                currentPopup.close();
                currentPopup = null;
            }
            popup.open(map, marker);
            currentPopup = popup;
        });
        google.maps.event.addListener(popup, "closeclick", function() {
            map.panTo(center);
            currentPopup = null;
        });
    }      

    function initMap() {
        map = new google.maps.Map(document.getElementById("map"), {
            center: new google.maps.LatLng(40.8319300, 16.4521000),
            zoom: 16,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            mapTypeControl: true,
            mapTypeControlOptions: {
                style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
            },
            navigationControl: false,
            navigationControlOptions: {
                style: google.maps.NavigationControlStyle.ZOOM_PAN
            }
        });
        addMarker(icon, 43.8219355, 16.4221334, '<b>test1</b>');
        addMarker(icon, 43.8312300, 16.4121000, '<b>test2</b>');
        addMarker(icon2, 43.8319300, 16.4521000, '<b>test3</b>');
   }
</script>
    <body onLoad="initMap()" style="margin:0px; border:0px; padding:0px;">
       <div id="map"></div>
    </body>

enter image description here

How to add linear gradient overlay on google maps iframe?

Hey Guys I am trying to add linear gradient on Google Maps iframe ,I successfully added the overlay div on the iframe using position relative and absolute concepts ;but if I do it that way I am not able to access the map.

.map{
    position: relative;
  
}
iframe{
    z-index: 1;
}
.overlay{
    position: absolute;
    width: 100%;
    height: 450px;
    background-image: linear-gradient(to right, rgba(255,0,0,0), rgb(51, 51, 51));
    top:0;
    z-index: 0;
}
<div class="map_section">
                <div class="map">
                    
                    <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d424143.2713133365!2d150.65178422173113!3d-33.84792702661292!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6b129838f39a743f%3A0x3017d681632a850!2sSydney%20NSW%2C%20Australia!5e0!3m2!1sen!2sin!4v1641639710179!5m2!1sen!2sin" width="100%" height="450" style="border:0;" allowfullscreen="" loading="lazy" class="map_bg" >
                      
                    </iframe>
                    <div class="overlay"></div>
                </div>

            </div>

Implementation of vue into existing grunt app

I have this application that via grunt runs a few tasks that return scripts and places them on a specific folder. I now want to add a task that runs and compile a vue file and returns the result script in the same destination folder. I have tried to follow this guide -> ‘https://gregtyler.co.uk/blog/vuejs-browserify-grunt?fbclid=IwAR3T_r07EFQywvZJYpBMAmaVebRdN2kHq29uDYy4KV45EGcfCvrAm6FnFg8’

But the end results runs the task but the return script is not generated and also the tasks return message is non existing. It only says “done”

se result here

This is my grunt file. The app uses the plugin ‘load-grunt-config’ to breakup my tasks per a file in ‘grunt’ folder.

/*global module, require*/
module.exports = function(grunt) {
// Get the version of the component from the package.json file.
var package = require('./package.json');
var componentVersion = package.version;
var componentName = package.name;

require('load-grunt-config')(grunt, {
    config: {
        // When changing version, don't forget to change version in the js too (the version number sent to analytics)!
        componentVersion: componentVersion,
        componentName: componentName,
        componentPath: 'dist/resources/'
    }
});
};

This is the file in grunt folder. The file is equivalent to my new vue-task

module.exports = {
browserify: {
    bundle: {
      src: './js/index.js',
      dest: '<%= componentPath %>/<%= componentName %>.<%= componentVersion %>-new.min.js'
    },
    options: {
      browserifyOptions: {
        debug: true
      },
      transform: [
        ['vueify']
      ]
    }
}
}

my package.json

{
  "name": "******",
  "version": "1.2.8",
  "browser": {
    "vue": "vue/dist/vue.common.js"
  },
  "dependencies": {
    "angular": "1.6.4",
    "browserify": "^17.0.0",
    "vue": "^2.6.14",
  },
   "devDependencies": {
    "copyfiles": "1.2.0",
    "grunt": "^1.4.1",
    "grunt-browserify": "^6.0.0",
    "grunt-contrib-less": "1.3.0",
    "grunt-contrib-requirejs": "1.0.0",
    "load-grunt-config": "0.19.2",
    "npm-html2js": "^0.1.8",
    "rimraf": "2.5.4",
    "vueify": "^9.4.1"
   },
  "scripts": {
    "build": "npm run clean && npm run html2js && npm run build:js && npm run copy:mgnl && npm run copy:assets && node node_scripts/addVersion.js && rimraf build && npm run compress",
"build:dev": "npm run clean && npm run html2js && npm run build:jsdev && npm run copy:mgnl && npm run copy:assets && node node_scripts/addVersion.js && rimraf build",
"clean": "rimraf dist && rimraf build && mkdir build && mkdir dist && mkdir dist/stores-and-retailers",
"html2js": "npm-html2js -i 'js/*.html' -o 'build/templates.js'",
"build:js": "grunt build",
"build:jsdev": "grunt build:dev",
"compress": "tar -C dist -zcf dist/stores-and-retailers.tar.gz stores-and-retailers",
"copy:mgnl": "copyfiles -u 1 'mgnl/**/*' dist/stores-and-retailers",
"copy:assets": "copyfiles -u 1 'assets/**/*' dist/stores-and-retailers/assets/",
"deploy-build": "npm run build",
"deploy-build:dev": "npm run build:dev",
   }
}

index.js file

const Vue = require('vue');

 import StoresAndRetailersMap from './components/StoresAndRetailersMap.vue'

 new Vue({
   el: '#storesAndRetailers',
   render: (createElement) => createElement(StoresAndRetailersMap)
 });

this is the vue component that i would like to compile and use

<template>
<div>
    <p>
        {{ msg }}
    </p>
</div>
  </template>
 <script>
        export default {
name: 'StoresAndRetailersMap',
props:{

},
data(){
    return {
        msg: "hello world"
    }
},
methods:{

},
created(){
}
 }

Issue with data to be displayed based on filter in reactjs

I am a new in reactjs and getting issue with data to be displayed based on loaded from server and filtered based on some tags.

The issue is data getting returned in the array map. But, not making it displayed to the elements.
I have created the codes in below link.

https://codepen.io/ssubham/pen/abLaodV

The codes are as :-

import React, {useState, useCallback, useEffect} from 'react';
import Axios from "axios";
import { Container, Grid, Stack, Typography, Button } from "@mui/material";
import moment from "moment";

import OwlCarousel from "react-owl-carousel";
import "owl.carousel/dist/assets/owl.carousel.css";
import "owl.carousel/dist/assets/owl.theme.default.css";

import {} from "./CourseContent.css";

const CourseContent = (props) => {
  const [courseData, setCourseData] = useState([]);
  const [programLevel, setProgramLevel] = useState({
    level: "personal",
    learning: "beginner"
  });

  // Filtering data based on level and learning state to view in Carousel.
  const filterCourseData = useCallback((pData, tempCourseData) => {
    console.log("filterCourseData ", tempCourseData.length);
    if (tempCourseData.length > 0) {
      const subCourseData1 = tempCourseData.filter((program) =>
        program.level.find(
          (items) =>
            Object.keys(items)[0] === pData.level &&
            Object.values(items)[0].find((items1) => items1 === pData.learning)
        )
      );
      setCourseData(subCourseData1);
      return subCourseData1;
    }
  }, []);

  // Fetching data from database to view.
  const fetchCourses = useCallback(() => {
    Axios.get(`https://demo.qortechno.com/api/v1/courses`)
      .then((response) => {
        if (response.data.success) {
          //console.log("coursecontent ",response.data.data)
          filterCourseData(programLevel, response.data.data);
        }
      })
      .catch((error) => {
        console.log(error);
      });
  }, [programLevel]);

  useEffect(() => {
    fetchCourses();
  }, [fetchCourses]);

  return (
    <Container>
      <Grid className={"courseMaterial"} sx={{ display: "flex", marginTop: 7 }}>
         <OwlCarousel
            navText={[
              "<i class='fas fa-chevron-left'></i>",
              "<i class='fas fa-chevron-right'></i>"
            ]}
            className="owl-theme owl-carousel" items={1} loop margin={10} nav dotsContainer="false"
 responsiveClass>
            {
              courseData.map((item, index) => {
console.log(item);
                return (
                  <div key={index}>
                    <Typography variant="h5" gutterBottom> {item.name} </Typography>
                    <Stack spacing={1} style={{ marginTop: "1.5em" }}>
                      <Typography variant="h5">{item.deliverymode}</Typography>
                      <Typography variant="h5"> {item.duration} Weeks
                      </Typography>
                    </Stack>
                  </div>
                );
              })
            }
          </OwlCarousel>
      </Grid>
    </Container>
  );
};

export default CourseContent;

Thanks…

Sharing Options not available on Android Tablet

I created a table out of a program and want to print it out.
for that, a new Page will be created by javascript with the table.
I don’t know why, but there are no sharing options for this page. I need to print that out.
On My mac in chrome it works.
Do you have any suggestions?

Here is the javascript code for that:

var divToPrint = document.getElementById("printTable");
newWin = window.open("");
newWin.document.write("<html><body><div id='table'></div></body></html>");
const table = newWin.document.getElementById("table");
table.appendChild(divToPrint);

Thank you very much!
enter image description here

CategoryAxis Labels in Y-axis are not shown properly

I am trying to draw a XY-chart, having both Y-axis and X-axis as categoryAxis, and also having several LineSeries for that.

As shown in picture, the Y-axis labels are overlapping!!

Screenshot from 2022-01-08 13-57-08

how can I solve that?

Here is my code:

  let myData = [
    {
      title: "2",
      customer1: "Internet_BB",
      customer2: "Space",
      customer3: "Space",
    },
    {
      title: "1",
      customer1: "Cloud_transmission_BB",
      customer2: "Internet_BB",
      customer3: "COLOCATION",
    },
    {
      title: "rhs",
      customer1: "COLOCATION",
      customer2: "InternalData_BB_(NIN)",
      customer3: "Internet_BB",
    }
  ];

    am4core.useTheme(am4themes_animated);
    var chart = am4core.create("XYChartDiv", am4charts.XYChart);
    chart.data = myData;

    var xAxis = chart.xAxes.push(new am4charts.CategoryAxis());
    xAxis.dataFields.category = "title";

    var yAxis = chart.yAxes.push(new am4charts.CategoryAxis());
    yAxis.renderer.minGridDistance =5;

    // Create series
    var series1 = chart.series.push(new am4charts.LineSeries());
    series1.dataFields.categoryY = "customer1";
    series1.dataFields.categoryX = "title";
    series1.name = "customer1";

    // same for series2 and ....

    const createLabel= (value) => {
      let range = yAxis.axisRanges.create();
      range.label.dataItem.text = value;
      range.contents.stroke = am4core.color("#396478");
      range.contents.fill = range.contents.stroke;
    }

    createLabel('Internet_BB');
    createLabel('Space');
    createLabel('Raw_space');
    createLabel('Cloud_transmission_BB');
    createLabel('Internal_IXP_BB');
    createLabel('COLOCATION');
    createLabel('InternalData_BB_(NIN)')

Discord.js 13 – Bot not playing local .mp3 file

I asked for help some days ago but no good answers, so, I’m trying again, hoping someone will explain where I did wrong and how to solve it.
So, this is my JS code, I’m new to JS so my code will not be perfect.

if (!message.member.voice.channel) {
            return
        } else if (message.member.voice.channel) {

            const connection = joinVoiceChannel({
                channelId: message.member.voice.channel.id,
                guildId: message.guild.id,
                adapterCreator: message.guild.voiceAdapterCreator
            });

            const player = createAudioPlayer();
            const resource = createAudioResource('./music/song.mp3');
            //play the song resource
            player.play(resource);
            connection.subscribe(player);
        }

Everything works fine, the bot joins the voice channel, no errors in the console BUT it doesn’t play the audio file

--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.7.4
- prism-media: 1.3.2

Opus Libraries
- @discordjs/opus: 0.5.3
- opusscript: not found

Encryption Libraries
- sodium: not found
- libsodium-wrappers: 0.7.9
- tweetnacl: not found

FFmpeg
- version: 4.4.1-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------

This is the console output when I use generateDependenciesReport() so I think everything’s okay.
Can someone explain me why my bot is not playing music but it joins voice channel without any problem ? Thanks a lot

how to pass data from api as prop in vuejs

I am getting data from api which I want to pass as prop to a child component

Parent component

<template>
    <div class="dashboard">
        <items name="Admins" value={{data.items.hubs}} bgColor="#a80c0c" />
    </div>
</template>
import Items from './Items.vue'
import { Admin } from '@/services/AdminService';
export default {
    name: "AdminDashboard",
    components: {
        Items
    },

    setup(){

    onMounted(() => {
      showLoader(true);
        Admin.getDashboardItems()
        .then((response) => {
            data.items = response.data.data
        })
        .catch((error) => {
        })
        .finally(() => {
          showLoader(false);
        });
    });
        return {
            data
        }

    }
}

I have gotten the value I need from the api and passed it to data.items

If i display it on the parent component.

It works fine but on the child component

it does not work

Child Component

<template>
    <div class="col-md-3">
        <div class="items" :style="{ backgroundColor: bgColor }">
            <div class="d-flex space-between">
                <div></div>
                <div>
                    <h5>{{ value }}</h5>
                    <span>{{ name }}</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>

export default {
    name: "Items",
    props: ["bgColor", "value", "name"]
}
</script>

The child components display {{data.items.hubs}} instead of the value of hub

The data from the api

{"data":{"users":1,"incubatees":1,"hubs":2,"investors":1,"events":0,"admins":3,"programs":0}}

how i can insert javascript variables into database

I have this function in javascirpt

enter code here

function addRow( i , name , first , second , final , partic , abc , Grade){

names[i] = name ;
fiM[i] = first ;
secM[i] = second ;
finalM[i] = final ;
parti[i] = partic ;
Y_N[i] = abc ;
grades[i] = Grade ;

}

enter code here

the parameters of this function I want to insert it into database
I tried so much but never work
please help

Global variable doesn’t change js [duplicate]

function get_info()
{
  var temp;
  con.connect(function (err) {
    if (err) throw err;
    con.query("SELECT * FROM customers", function (err, result, fields) {
      if (err) throw err;
      temp = result;
      console.log(temp);
    });
  });
  console.log(temp);
}

when I run the function, the console.log(temp) at the end of the function shows “undefined” even though it shows the data when I do console.log(temp) in the inside function. I think the problem is that the global variable doesn’t change but I don’t know how to fix it. Any ideas?

node cron job on existing express server?

I want to run a cronjob to aggregate data from my users for every hour. Currently there’s quite a lot of data to aggregate and i’d ideally want to use python, and am currently running an express server.

I’m wondering – how would I run these scripts from express?

import psycopg2 as pg
import pandas as pd
from datetime import datetime, timedelta

import db_conn

def handler(thing, context):
    
    """
    this connects, calculates the last hour, then writes a new line to a table in postgress.
    """
    conn = db_conn.main()

    #step one
    current_hour_epoch, previous_hour_epoch = calculate_last_utc_hour()
    #step two
    df = query_sentiment_statistics(conn, previous_hour_epoch, current_hour_epoch)
    #step three
    write_db(conn, df, previous_hour_epoch, 1)

    pass

def calculate_last_utc_hour():

    """
    this is used for the cronjob processing.
    """
    
    current_time = datetime.now()
    current_hour_start = current_time.replace(minute=0, second=0, microsecond=0)
    previous_hour_start = current_hour_start - timedelta(hours = 1)

    current_hour_epoch = datetime.timestamp(current_hour_start)
    previous_hour_epoch = datetime.timestamp(previous_hour_start)
    print("query from ", previous_hour_epoch, "to", current_hour_epoch)
    return current_hour_epoch, previous_hour_epoch

def query_sentiment_statistics(conn, lower, upper):

    """
    Gathers sentiment data statistical information.
    """

    sql = """
        SELECT 
            user_id,
            AVG(sentiment) as sentiment,
            AVG(magnitude) as magnitude,
            SUM(sentiment) as total_sentiment,
            SUM(magnitude) as total_magnitude,
            MAX(sentiment) as max_sentiment,
            MIN(sentiment) as min_sentiment,
            COUNT(user_id) as count
        FROM
            sentiments
        WHERE
            created
            BETWEEN %s and %s
        GROUP BY
            user_id;
    """
    try:
        cur = conn.cursor()
        df = pd.read_sql(sql, con=conn, params=(lower, upper))
        cur.close()
        return df
    except (Exception, pg.DatabaseError) as error:
        print(error)
    pass

def write_db(conn, dataframe, lower, detail = 1):

    # set the additional columns required to be written into the table
    dataframe['detail'] = detail
    dataframe['created'] = lower
    
    try:
        #writes to new table that aggregates sentiments
        dataframe.to_sql('sentiments_aggregate', con = conn, if_exists = 'append', index = False)
    except (Exception, pg.DatabaseError) as error:
        print(error)
    pass

if __name__ == '__main__':
   
    pass

Would it just be easier to do the same code in javascript? something liek this,

const { db } = require("./db");


const sql = "SELECT user_id, AVG(sentiment) as sentiment, AVG(magnitude) as magnitude, SUM(sentiment) as total_sentiment,  SUM(magnitude) as total_magnitude,MAX(sentiment) as max_sentiment, MIN(sentiment) as min_sentiment,COUNT(user_id) as count FROM sentiments WHERE created BETWEEN %s and %s GROUP BY user_id;"

db.query(sql, [id], (err, rows) => {
   
});
}

and using node-cron to replicate the time intervals?

thanks!

How do I toggle a css class to elements of the same class, on click of another single element, in pure JavaScript?

I want to toggle a css class on all elements with the same class, on click of another element. I had it working with jQuery but need to switch to pure JavaScript. The lovely jQuery that works:

$(function () {
            $("#logo").click(function () {
                $(".grey").toggleClass("white",1000);
                $(".red").toggleClass("orange",1000);
        });
        });

—when you click on the element with id=”logo”, everything with class=”grey” toggles “white” class and everything with class=”red” toggles “orange”. Perfect.

I’ve googled like mad for a solution to this, but I can’t get anything to work even though it seems like a simple thing — I’ve taken over a day to try to learn what I need to know but a solution is escaping me. (Scripting is not my first language by any stretch.) Thank you in advance.

How to use _sortBy in an array of objects that contains nested array of objects

I have a list of array of objects that contains a nested array of objects like so:

const mainList = [
{
    id:'001',
    category: 'A',
    content: [ 
        {
            title: 'Apples',
            language: 'en'
        },
        {
            title: '苹果',
            language: 'zh-cn'
        },
        {
            title: '苹果HK',
            language: 'zh-hk'
        },
    ],
},
{
    id:'002',
    category: 'B',
    content: [
        {
            title: 'Grapes',
            language: 'en'
        },
        {
            title: '葡萄',
            language: 'zh-cn'
        },
        {
            title: '葡萄HK',
            language: 'zh-hk'
        },
    ],
},
{
    id:'003',
    category: 'C',
    content: [
        {
            title: 'Bananas',
            language: 'en'
        },
        {
            title: '香蕉',
            language: 'zh-cn'
        },
        {
            title: '香蕉HK',
            language: 'zh-hk'
        },
    ]
}
]

I want to display this list using lodash _sortBy, by its title in alphabetical order like this:

Apples, Bananas, Grapes

My approach:

console.log(_sortBy(mainList.content.title))

But the result comes back with undefined at index 0

Thanks in advance!