• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

how to hide previous markers when new markers added in google map javascript api

javascriptphphtml


PHP Snippet 1:

const THRESHOLD = 3 // up to 3 active markers
let list = [] // list of markers

const onAddMarker = marker => {

    // init marker
    let marker = new google.maps.Marker([...opts]) 

    // push marker to list
    list.push(marker)

    // check list length and remove oldest marker (if needed)
    if (list.length > THRESHOLD)
        list.shift().setMap(null)
    
}

Related Snippets

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

how to insert data into select2 search input after scan using qrcode

Can't remotely connect to MySQL error (13) with PHP script, connecting through CLI works

Inserting Country Selection into MySQL PHP [duplicate]

Remove product downloads section in woocommerce email notifications

Wordpress 'post_type_link' hides permalink

get folder directory from input type file - PHP

Error converting docx to pdf using Unoconv

What is the function of the (new Date()).getTime() in PHP?

How can I access an array/object?

Hide specific products from unlogged users based in product category in WooCommerce

PHP sort array of objects by two properties

Composer fails with kylekatarnls/update-helper on new homestead

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

renameColumn migration fails for existing column with columns does not exist error

About Contact Privacy policy Terms and conditions