• 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

protect images from being copied

How to test a php login connected to a mysql db through xampp?

Is it possible to change the table name in the migration file-laravel

How to increase the PHP upload limits [duplicate]

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Remove country code from phone number?

I want to store data in new index as per my key in php [duplicate]

Show rotation of tweets using current day of month

PHP array stringify

How to get array values using foreach in laravel

Laravel Factory not calling callback 'afterCreating'

How to install PHP composer inside a docker container

How to convert binary string to normal string in php

Laravel post contact form giving me error 419

About Contact Privacy policy Terms and conditions