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 1059127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:07:34+00:00 2026-05-16T18:07:34+00:00

I successfully installed epoly.js for V2 and got it working. However in V3 I

  • 0

I successfully installed epoly.js for V2 and got it working.

However in V3 I get this error in my console:

ReferenceError: Can’t find variable: GPolygon

Any ideas?

  • 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-05-16T18:07:35+00:00Added an answer on May 16, 2026 at 6:07 pm

    OK I have found a solution courtesy of the guy(s) at http://dyve.posterous.com/?tag=googlemaps

    They provide 2 routines:

    if (!google.maps.Polygon.prototype.getBounds) {
        google.maps.Polygon.prototype.getBounds = function(latLng) {
            var bounds = new google.maps.LatLngBounds();
            var paths = this.getPaths();
            var path;
            for (var p = 0; p < paths.getLength(); p++) {
                path = paths.getAt(p);
                for (var i = 0; i < path.getLength(); i++) {
                    bounds.extend(path.getAt(i));
                }
            }
            return bounds;
        }
    }
    
    if (!google.maps.Polygon.prototype.contains) {
        google.maps.Polygon.prototype.contains = function(latLng) {
            // Outside the bounds means outside the polygon
            if (!this.getBounds().contains(latLng)) {
                return false;
            }
            var lat = latLng.lat();
            var lng = latLng.lng();
            var paths = this.getPaths();
            var path, pathLength, inPath, i, j, vertex1, vertex2;
    
            // Walk all the paths
            for (var p = 0; p < paths.getLength(); p++) {
    
                path = paths.getAt(p);
                pathLength = path.getLength();
                j = pathLength - 1;
                inPath = false;
                for (i = 0; i < pathLength; i++) {
                    vertex1 = path.getAt(i);
                    vertex2 = path.getAt(j);
                    if (vertex1.lng() < lng && vertex2.lng() >= lng || vertex2.lng() < lng && vertex1.lng() >= lng) {
                        if (vertex1.lat() + (lng - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < lat) {
                            inPath = !inPath;
                        }
                    }
                    j = i;
                }
                if (inPath) {
                    return true;
                }
            }
            return false;
        }
    }
    

    I then simply add this code

    function initialize() {
      var areas = [];
      var coords = [];
      var latlng = new google.maps.LatLng(53.85, -2.15);
      var myOptions = {
        zoom: 12,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
      var marker = new google.maps.Marker({
          position: latlng, 
          map: map,
          title:"Hello World!",
          draggable: true
      });   
      coords[0] = [
          new google.maps.LatLng(53.9, -2.15),
          new google.maps.LatLng(53.91, -2.05),
          new google.maps.LatLng(53.85, -2.10),
          new google.maps.LatLng(53.9, -2.15)
      ];
      areas[0] = new google.maps.Polygon({
        paths: coords[0],
        strokeColor: "#FF0000",
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: "#FF0000",
        fillOpacity: 0.35
      });
      areas[0].setMap(map);
      coords[1] = [
          new google.maps.LatLng(53.9, -2.14),
          new google.maps.LatLng(53.88, -2.05),
          new google.maps.LatLng(53.85, -2.09),
      ];
      areas[1] = new google.maps.Polygon({
        paths: coords[1],
        strokeColor: "#00FF00",
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: "#00FF00",
        fillOpacity: 0.35
      });
      areas[1].setMap(map);
      google.maps.event.addListener(marker, 'dragend', function(point) {
        for(var area = 0; area <= areas.length; area++) {
          alert(area+" "+areas[area].contains(point.latLng));
        }
      });
    }
    

    Drag the pin over 1 or both of the triangles to get true/false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've successfully installed Solr 1.4.1, but I can't get Tika 0.4 (which is included
I can't get my site running with south. I've successfully installed south, and I
I successfully installed Opencv via sudo apt-get install libcv-dev libcv4 libcvaux-dev libcvaux4 libhighgui-dev libhighgui4
I successfully installed the latest QuantumGrid from DevExpress, but I've never worked with this
I have successfully installed Eclipse and the Android SDK on Fedora 16. However, when
I have just successfully installed CakePHP and I see that I can edit the
I successfully installed & linked the static library of Kal Calendar. However, I'm struggling
I have successfully installed SVN on a Windows XP machine and can connect to
I have successfully installed mercurial on media temple grid server. But I can not
I have successfully installed sshd on cygwin. I can ssh to it from within

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.