Tinted map polygons on Google Maps with an external map shade

Initially, to highlight my polygon in this case, I implemented the following code snippet: Highlight polygon and tint rest of map using Google Maps

Below is the Angular code I utilized:

var boundaries          = [];

// defining a large area
var overlay             = [
  new $rootScope.googleApi.LatLng(80.0, -90.0),
  new $rootScope.googleApi.LatLng(-60.0, -90.0),
  new $rootScope.googleApi.LatLng(-60.0, 90.0),
  new $rootScope.googleApi.LatLng(80.0, 90.0)
];

// creating my polygon
angular.forEach(settings_boundaries, function(val, key) {
  boundaries.push(new $rootScope.googleApi.LatLng(val[1], val[0]));
});

// constructing a polygon with overlay initially
var poly = new $rootScope.googleApi.Polygon({
  paths: [overlay, boundaries],
  strokeColor: "blue",
  strokeWeight: "1",
  fillColor: "black",
  fillOpacity: 0.4,
  clickable: false
});

poly.setMap(interactiveMap);

The main issue now lies in, When I employ these coordinates (which I don't recall where I obtained originally):

[[1.6101837158203125,49.00274483644452],
[1.6294097900390625,49.01175312475694],
[1.5947341918945312,48.98787759766659],
[1.6101837158203125,49.00274483644452]]

Everything functions correctly (as depicted here).

However, if I use these set of coordinates instead:

[[1.6809940338134766,48.98337149775796],
[1.6791915893554688,48.96849847697763],
[1.7185020446777344,48.995199140974066],
[1.6809940338134766,48.98337149775796]]

This no longer produces the desired outcome.
As seen here.

I employed this website to generate the coordinates :
(refer to screenshot)

I have spent considerable time trying to figure out the root cause of the problem, but it remains elusive. The coordinates are nearly identical. The first lat, lon values match for both cases.

If you have any insights (there might be something unique about the coordinates), I would appreciate your input!

Thank you!

Answer №1

The triangle's coordinates appear to be correct structurally. The main difference between the two triangles is their drawing direction - the first one is drawn clockwise, while the second one is drawn counterclockwise. I have encountered a similar situation in the past, although I cannot recall the specific source. To address this issue, you can try reversing the direction of drawing for the second triangle as follows:

     [[1.6809940338134766,48.98337149775796],
     [1.7185020446777344,48.995199140974066]
     [1.6791915893554688,48.96849847697763]
     [1.6809940338134766,48.98337149775796]]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the functionality of Google Chrome's "New Tab" iframes?

Have you ever wondered about those 8 small iframes displaying your most visited websites? How do they capture snapshots of the websites? How are the websites chosen for display? And most importantly, how do they actually work? Edit: I want to learn how to ...

Enhance headers with authLink in react-apollo post-authorization

Utilizing the Github Graphql API has been quite a journey for me. Upon the initial load of my application, I direct the user to fetch an access_token. The process works smoothly, however, since the app has already loaded, I face the challenge of updating ...

Having trouble with ui-sref functionality within a Bootstrap dropdown menu

In the header.html file, I have the following angular code: <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> &l ...

Understanding the functionality of $exceptionHandlerIn order to fully

While exploring angularjs, I discovered a method to manage uncaught exceptions using the built-in $exceptionHandler service. As stated in the documentation, I am manually handling exceptions by incorporating try {...} - catch(e). Below is an example: try ...

Confirm the object received from the API and assign default values

Seeking to extract data from an API and verify if all fields are strings, but if they are missing I aim to assign default values. My intention was to utilize the yup library to validate the object accordingly, ensuring that the returned function is prope ...

Having trouble adding elements (after the initial iteration) using the push() method in JavaScript

I'm facing an issue where I have a string and an array, but I'm unable to push elements after the first iteration. Below is the code I'm using: response1 = "hello"; var arr = [""]; arr.push(response1); console.log("First position " + arr[0 ...

Utilize a Google Chrome extension to interact with the DOM of the active tab

Alright, so I've got a good grasp on JavaScript/jQuery and can use them for various tasks. However, my current challenge involves manipulating the DOM of the open tab. I'm curious to know if it's feasible or if all the actions performed by a ...

Using Angular in my workflow significantly increases the amount of static code within my HTML files

I am currently testing my app on a live Rails server and encountering issues with Angular integration. To better examine the code, I have disabled config.assets.js_compressor = :uglifier in production.rb file. The challenge lies in the fact that Angular ...

What is the method for retrieving the XMLHttpRequest errors registered with addEventListener?

I am struggling to find a solution. https://i.stack.imgur.com/bRJho.gif ...

Adjusting the StrokeWidth in pixels/em units on fabricjs

When adding a rectangle or circle to the canvas and adjusting the strokeWidth using a range input, how can we determine the value of strokeWidth in pixels, em, or percent? For instance, if we set strokeWidth to 5 within a range of 1-10, how much does the a ...

Hide React micro animations on component using display:none

Is there a way to make this component appear on button click with a smooth ease-in expand or popout animation? I'd like the transition to be smoother rather than it just appearing suddenly. const CardExample = () => { const [show, setShow] = use ...

The initial render of Next.js is not properly loading the CSS files

Encountering an issue with the initial load of the mobile app version; it seems that the CSS of my component covering the page is not loading correctly on the first screen load. However, when resizing to desktop and then switching back to mobile view, the ...

Turborepo users encountering peculiar errors with Remix integration

Currently, I am working on integrating a remix example for my library, react18-themes, and have a functional example available here. However, I am facing some unusual errors when attempting to set up the example in the monorepo. TypeError: Unknown file ext ...

JavaScript is failing to pass the argument value

Whenever I attempt to pass a value on an onclick=function('') function, the value does not seem to get passed correctly while ($row = mysqli_fetch_array($result)) { $id = $row['id']; echo '<a href="#" onclick="DeleteUse ...

The error I encountered with the Typescript React <Select> onChange handler type was quite

Having an issue while trying to attach an onChange event handler to a Select component from material-ui: <Select labelId="demo-simple-select-label" id="demo-simple-select" value={values.country} onChange={handleCountryChange} ...

Capture XMLHttpRequest request and manually send a 200 status response using vanilla JavaScript

After extensive research, I found conflicting information on this topic. I need to intercept an XMLHttpRequest and simulate a 200 status response from the backend using plain Javascript. This is specifically for testing purposes. So far, I have made pro ...

What is the best way to create a collage of images with a random and unique arrangement?

Recently, I stumbled upon a website and was intrigued by the unique effect of images randomly appearing on the screen. I'm curious about how this effect can be achieved. Is it possible to use CSS Grid to divide the screen and designate some grid ite ...

Is there an AngularJS filter that can capture every state change?

What is the best way to implement a server-side filter in an Angular application when switching between controllers? I am aiming to enable deep linking within my app, while also checking for the presence of an HTTP Basic Authorization token in memory. If ...

Authorization missing in Select2 Ajax request

Encountering an issue while attempting a get request to a secure endpoint that requires an Auth token. Despite fetching the token asynchronously from chrome.storage, it fails to be included in the ajax request and results in a 401 error ("Authorization hea ...

Obtaining the ID from a URL in node.js

As a newcomer to the world of Javascript and node.js, I am venturing into creating a REST API with URLs structured as follows: /user/{userId}/docs The goal is to extract the value of {userId}, which, for instance, in the URL /user/5/docs would be 5. Wh ...