• 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 do I refresh a DIV content?

Connecting an HTML webpage to a SQL Server

How to use React Router with Laravel?

Fatal error: Trait 'LaminasDbAdapterLaminasDbAdapterAdapterInterface' not found in /var/www/vendor/laminas/laminas-db/src/Adapter/Adapter.php

Laravel 5 controller sending JSON integer as string

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

onKeyUp event calculation not working on the following rows from php generated forms except the first one

Laravel You requested 1 items, but there are only 0 items available

Laravel Multi-language routes without prefix

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

How can i call a function that executes an fpdf based on the choice of a form selector?

How to get monthly wise data in laravel

Render the content of default_filter.php in Joomla front-end

Could not decode a text frame as UTF-8.

About Contact Privacy policy Terms and conditions