• 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

How to redirect to another page and call a Function there on Angular ng-click

Match single unknown parameter php (Morse-code Regex)

How do I truncate a decimal in PHP?

php code to send checkbox form results to email

Mysqli multi query error

How to reset Laravel AuthManager/guards in between API calls in tests?

Why does using salted hash on python and php give me different results?

PHP SoapClient: set a namespace without prefix

Laravel PHP: multiple project run at the same time [closed]

Laravel 5 issue with wherePivot

Return new collection without modifying original collection

Extract house numbers from address string

Session timeout in Yii2

Upload a file Using PHP and JavaScript

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

About Contact Privacy policy Terms and conditions