Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:12:00+00:00 2026-06-16T00:12:00+00:00

im looking to setup my map with toggle markers, so that when a user

  • 0

im looking to setup my map with toggle markers, so that when a user checks/unchecks a series of checkbox’s under the map, whichever checkbox’s are checked are the category of markers that are shown, so if 3 out of 4 checkbox’s are checked ie: bar, school, resturaunt, those are the markers by category that are shown, and if someone unchecks that 4th marker or any number of them, they will become invisible”in sense”, which isnt working, ive looked all over and couldnt find any references that help. im new to javascript and am proficient in PHP. i set up the locations[] array to be a 4 column out and infinite down. so for me to get the “place type” its locations[i][4]… ive been at this for days and i cant get any better. ive tried all possible combinations i can think of. like i said . im a php scripter. ANY help is much appriciated

<script type="text/javascript">
//PHP - Lat,Lng ARRAY
var locations = [
<?php
$x = 0; $i = 0; $j = 0; $y = 0; $z = 0; $a = 0; $b = 0; $c = 0;
for($aa = 0; $aa < $count; $aa++) {
$content = '<div class="coupon"><div class="ribbon"><div class="ribbon-stitches-top"></div><strong class="ribbon-content"><h1>'.$deal[$y].'</h1></strong><div class="ribbon-stitches-bottom"></div></div><div class="picture_coupon"><img src="'.$deal_photo[$b].'" width="150" height="100" /></div><div class="deal"><center><h1>'.$deal[$y].'</h1>'.$deal_info[$a].'<b>Expires: '.$deal_expiration[$c].'</b></center></div></div>';

echo "['" . $business_name[$x] . "'," . $lat[$i] . "," . $lng[$j] . "," . "'$content'" . ",".$type[$id]. "],";
$x++; $i++; $j++; $id++; $y++; $z++; $a++; $b++; $c++;
}
?>
['' , , ,'' , '']
];  
//PHP - Lat,Lng ARRAY 
  var map;

  function initialize() {
    var myOptions = {
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map_canvas'),
        myOptions);

    // Try HTML5 geolocation
    if(navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        var pos = new google.maps.LatLng(position.coords.latitude,
                                         position.coords.longitude);

// INVERSE CODE PHP DYNAMIC

var infowindow = new google.maps.InfoWindow();

var marker, i;


//Marker Icon Generation.. Will be changed WHEN make new colors
var blue = '../images/map-icons/blue.png';

for (i = 0; i < locations.length; i++) {  
  marker = new google.maps.Marker({
    position: new google.maps.LatLng(locations[i][1], locations[i][2]),
    map: map,
    icon: blue // iconType[$num] 
  });

  google.maps.event.addListener(marker, 'click', (function(marker, i) {
    return function() {
      infowindow.setContent(locations[i][3]);
      infowindow.open(map, marker);
    }
  })(marker, i));
}

// INVERSE CODE PHP DYNAMIC
// GEO LOCATION SET CENTER AND ERROR HANDLING

        map.setCenter(pos);
      }, function() {
        handleNoGeolocation(true);
      });
    } else {
      // Browser doesn't support Geolocation
      handleNoGeolocation(false);
    }
  }

  function handleNoGeolocation(errorFlag) {
    if (errorFlag) {
      var content = 'Error: The Geolocation service failed.';
    } else {
      var content = 'Error: Your browser doesn\'t support geolocation.';
    }   

// GEO LOCATION SET CENTER AND ERROR HANDLING

  }

  google.maps.event.addDomListener(window, 'load', initialize);

//=================ATTEMPT AT toggle Marker Checkbox

// == shows all markers of a particular category, and ensures the checkbox is checked ==

  function show(category) {

    for (var i=0; i<locations.length; i++) {

      if (locations[i].mycategory == category) {

        locations[i].setVisible(true);

      }

    }

    // == check the checkbox ==

    document.getElementById(category+"box").checked = true;

  }



  // == hides all markers of a particular category, and ensures the checkbox is cleared ==

  function hide(category) {

    for (var i=0; i<locations.length; i++) {

      if (locations[i].mycategory == category) {

        locations[i].setVisible(false);

      }

    }

    // == clear the checkbox ==

    document.getElementById(category+"box").checked = false;

    // == close the info window, in case its open on a marker that we just hid

    infowindow.close();

  }



  // == a checkbox has been clicked ==

  function boxclick(box,category) {

    if (box.checked) {

      show(category);

    } else {

      hide(category);

    }

    // == rebuild the side bar

    makeSidebar();

  }  
 /*HTML*/<input type ="checkbox" name="resturauntbox" onclick="boxclick(this,'resturaunt')"><label></label>
     <input type ="checkbox" name="barbox" onclick="boxclick(this,'bar')"><label></label>

//============================================CHECKBOX //HTML

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:12:00+00:00Added an answer on June 16, 2026 at 12:12 am

    I just set up a php for loop with a variable to catch all of the categories and one to turn them on and the other to hide them.

    function checkAll(field) {
      for (j = 0; j < field.length; j++) {
        field[j].checked = true;
    
      }
    
      for (var index = 0; index < 1; index++) {
        category = "";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(true);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(true);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(true);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(true);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(true);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(true);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(true);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(true);
          }
        }
      }
    }
    
    function uncheckAll(field) {
    
      for (j = 0; j < field.length; j++) {
        field[j].checked = false;
    
      }
    
      for (var index = 0; index < 1; index++) {
        category = "American";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(false);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "Asian";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(false);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "Deli - Cafe";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(false);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "Ethnic";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(false);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "Italian";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(false);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "Mexican";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(false);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "Seafood";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(false);
          }
        }
      }
      for (var index = 0; index < 1; index++) {
        category = "Sushi";
        for (var i = 0; i < locations.length; i++) {
          if (locations[i][4]) {
            markers[i].setVisible(false);
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the standard user tables that ASP.net setup and I'm looking to
I am looking to setup a Server that accepts a URL with a few
I am looking for a Google maps library/API/.NET function that simply shows the map
I am looking to setup a relationship where a user can create a post
I am looking to setup architecture for entity framework that will break apart the
I am looking to setup Amazon EC/2 nodes on rails with Riak. I am
I'm looking to setup a custom route which supplies implicit parameter names to a
I'm looking to setup emacs to allow me to use perforce without having to
I'm looking for a good setup for learning C++ and eventually Python on Mac
I am looking to have a SharePoint Extranet Portal setup for my partner clients.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.