Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #11 from gmccrackin/master

_ccw function fix
  • Loading branch information...
commit 4fe946a430a3fe6439c1714f86d22abdb7c5e4e2 2 parents 68b9050 + 60f2762
@JasonSanford authored
Showing with 28 additions and 10 deletions.
  1. +8 −9 GeoJSON.js
  2. +20 −1 index.htm
View
17 GeoJSON.js
@@ -164,16 +164,15 @@ var GeoJSON = function( geojson, options ){
var _ccw = function( path ){
var isCCW;
+ var a = 0;
for (var i = 0; i < path.length-2; i++){
- a = ((path[i+1].lat() - path[i].lat()) * (path[i+2].lng() - path[i].lng()) - (path[i+2].lat() - path[i].lat()) * (path[i+1].lng() - path[i].lng()));
- if(a > 0){
- isCCW = true;
- break;
- }
- else if(a < 0){
- isCCW = false;
- break;
- }
+ a += ((path[i+1].lat() - path[i].lat()) * (path[i+2].lng() - path[i].lng()) - (path[i+2].lat() - path[i].lat()) * (path[i+1].lng() - path[i].lng()));
+ }
+ if(a > 0){
+ isCCW = true;
+ }
+ else{
+ isCCW = false;
}
return isCCW;
};
View
21 index.htm
@@ -349,6 +349,9 @@
if(currentFeature_or_Features[i].length){
for(var j = 0; j < currentFeature_or_Features[i].length; j++){
currentFeature_or_Features[i][j].setMap(map);
+ if(currentFeature_or_Features[i][j].geojsonProperties) {
+ setInfoWindow(currentFeature_or_Features[i][j]);
+ }
}
}
else{
@@ -372,10 +375,26 @@
currentFeature_or_Features = new GeoJSON(JSON.parse(document.getElementById("put_geojson_string_here").value));
if (currentFeature_or_Features.length){
for (var i = 0; i < currentFeature_or_Features.length; i++){
- currentFeature_or_Features[i].setMap(map);
+ if(currentFeature_or_Features[i].length){
+ for(var j = 0; j < currentFeature_or_Features[i].length; j++){
+ currentFeature_or_Features[i][j].setMap(map);
+ if(currentFeature_or_Features[i][j].geojsonProperties) {
+ setInfoWindow(currentFeature_or_Features[i][j]);
+ }
+ }
+ }
+ else{
+ currentFeature_or_Features[i].setMap(map);
+ }
+ if (currentFeature_or_Features[i].geojsonProperties) {
+ setInfoWindow(currentFeature_or_Features[i]);
+ }
}
}else{
currentFeature_or_Features.setMap(map);
+ if (currentFeature_or_Features.geojsonProperties) {
+ setInfoWindow(currentFeature_or_Features);
+ }
}
}
function setInfoWindow (feature) {
Please sign in to comment.
Something went wrong with that request. Please try again.