in Education by
The background purpose is that I want to divide a country into different regions. For example, divide USA into all its states. Each state should be clickable or selectable in a checkbox way, so that I can select multiple states. All this is a part of a searching filter. The purpose of dividing a country into regions is that each region contains for example a number of hotels, so that when I select a region, I narrow down the filter to only hotels that exist in that region. Is there a way to accomplish this using Google Maps? Most likely I won't create very many regions, so if the only way is to draw the lines manuelly, thats acceptable. If your solution is something else then what I'm suggestion, please write your solution anyway! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
This is an old question, but I'll answer anyways if anyone encounters this kind of problem too. I'm currently working on a similar kind of task where I have to create selectable roads. I came up with a solution by using JavaScript "classes" containing properties, listeners and methods, and adding them to map canvas with setMap(map) function in a loop. Basically this creates the map canvas with selectable areas dynamically, but you still have to create a data set manually that contains the areas, their name and other information and their coordinate boundaries. I think it's also easy to create selectable rectangles, circles, road etc. other objects with hover effects using this method. Pseudocode: function initialize() { // initialize Google Maps canvas normally // areaDataSet variable is an array of containing all areas to be // drawed and the necessary information needed to create polygon areas // (coordinate boundaries, and so on) // For example var areaDataSet = [{ "name" : "Texas", "coords" : [latitudes and longitudes], "hasHotelsInCoords" : [...] }, { ... } ] var areas = []; for ( i in areaDataSet ) { var area = new google.maps.Polygon({ path: [coordinates as google.maps.LatLng objects] }); areas.push(new MyAreaClass(area)); } for ( i in areas ) { areas[i].setMap(map); } } function MyAreaClass(areaData) { this.area = areaData; var selected = false; // not selected by default // + all other data you want the areas to contain // Add listeners using google.maps.event.addListener to all class instances // when they are constructed. // for instance: google.maps.event.addListener(area, 'mouseover', function() { if (selected == false) { area.setOptions( { [options you want to set when area is hovered but not selected, for instance, color change] }); }; else { area.setOptions({ [options you want to set when area is hovered and selected] }); }; }); // Add listeners also for when area is not hovered anymore, respectively, // and other methods you might want to call when areas are being interacted with. }; Hopefully this helps! Best regards

Related questions

0 votes
    What is Distribution and map overlay in Google Analytics?...
asked Oct 3, 2020 in Technology by JackTerrance
0 votes
    I'm using the official Google Maps Flutter plugin to show maps and it works perfectly well but now I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    Is it possible to confirm if a place name exists for a specified coordinates via PHP? In other words, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    Is it possible to confirm if a place name exists for a specified coordinates via PHP? In other words, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
0 votes
    I store all of the Google Maps marker objects in a single array. Right now I am trying to set up ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I am trying to create an app using AngularJS that takes a user's location (from their mobile) and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    I am trying to create an app using AngularJS that takes a user's location (from their mobile) and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 12, 2022 in Education by JackTerrance
0 votes
    I am following up with the Wirecloud User Guide available here https://wirecloud.readthedocs.io/en/latest/ ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I am using this for slide up layout in my map fragment but my app just crashing again and again ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I'm getting Authorization failure when trying to display a map in a flutter project using the google maps ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am using this for slide up layout in my map fragment but my app just crashing again and again ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    See the picture below. In my application (with MapView) usage, I would like to use such default markers ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    How to get list of restaurants by using google maps. I want to get more than 20. Is it possible? ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I am using the following code to cause events based upon button clicks. When I click the button,the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
...