Giter VIP home page Giter VIP logo

geojson-google-maps's People

Contributors

gmccrackin avatar jasonsanford avatar ronaldpk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geojson-google-maps's Issues

No MapCenter or FitBounds feature

Hey Jason,

Added:

    GeoJSON.mapCenter()
    GeoJSON.getBounds()

Modified your code:

var GeoJSON = function( geojson, options ){

        var llbounds = new google.maps.LatLngBounds();  

        Function.prototype.getCenter = function(){
            return llbounds.getCenter();
        }

        Function.prototype.getBounds = function(){
            return llbounds;
        }


        var _geometryToGoogleMaps = function( geojsonGeometry, opts, geojsonProperties ){

        var googleObj;

        switch ( geojsonGeometry.type ){
            case "Point":
                opts.position = new google.maps.LatLng(geojsonGeometry.coordinates[1], geojsonGeometry.coordinates[0]);
                llbounds.extend(opts.point);
                googleObj = new google.maps.Marker(opts);
                if (geojsonProperties) {
                    googleObj.set("geojsonProperties", geojsonProperties);
                }
                break;

            case "MultiPoint":
                googleObj = [];
                for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
                    opts.position = new google.maps.LatLng(geojsonGeometry.coordinates[i][1], geojsonGeometry.coordinates[i][0]);
                    llbounds.extend(opts.point);
                    googleObj.push(new google.maps.Marker(opts));
                }
                if (geojsonProperties) {
                    for (var k = 0; k < googleObj.length; k++){
                        googleObj[k].set("geojsonProperties", geojsonProperties);
                    }
                }
                break;

            case "LineString":
                var path = [];
                for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
                    var coord = geojsonGeometry.coordinates[i];
                    var ll = new google.maps.LatLng(coord[1], coord[0]);
                    llbounds.extend(ll);
                    path.push(ll);
                }
                opts.path = path;
                googleObj = new google.maps.Polyline(opts);
                if (geojsonProperties) {
                    googleObj.set("geojsonProperties", geojsonProperties);
                }
                break;

            case "MultiLineString":
                googleObj = [];
                for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
                    var path = [];
                    for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
                        var coord = geojsonGeometry.coordinates[i][j];
                        var ll = new google.maps.LatLng(coord[1], coord[0]);
                        llbounds.extend(ll);
                        path.push(ll);
                    }
                    opts.path = path;
                    googleObj.push(new google.maps.Polyline(opts));
                }
                if (geojsonProperties) {
                    for (var k = 0; k < googleObj.length; k++){
                        googleObj[k].set("geojsonProperties", geojsonProperties);
                    }
                }
                break;

            case "Polygon":
                var paths = [];
                var exteriorDirection;
                var interiorDirection;
                for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
                    var path = [];
                    for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
                        var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][1], geojsonGeometry.coordinates[i][j][0]);
                        llbounds.extend(ll);
                        path.push(ll);
                    }
                    if(!i){
                        exteriorDirection = _ccw(path);
                        paths.push(path);
                    }else if(i == 1){
                        interiorDirection = _ccw(path);
                        if(exteriorDirection == interiorDirection){
                            paths.push(path.reverse());
                        }else{
                            paths.push(path);
                        }
                    }else{
                        if(exteriorDirection == interiorDirection){
                            paths.push(path.reverse());
                        }else{
                            paths.push(path);
                        }
                    }
                }
                opts.paths = paths;
                googleObj = new google.maps.Polygon(opts);
                if (geojsonProperties) {
                    googleObj.set("geojsonProperties", geojsonProperties);
                }
                break;

            case "MultiPolygon":
                googleObj = [];
                for (var i = 0; i < geojsonGeometry.coordinates.length; i++){
                    var paths = [];
                    var exteriorDirection;
                    var interiorDirection;
                    for (var j = 0; j < geojsonGeometry.coordinates[i].length; j++){
                        var path = [];
                        for (var k = 0; k < geojsonGeometry.coordinates[i][j].length; k++){
                            var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][k][1], geojsonGeometry.coordinates[i][j][k][0]);
                            llbounds.extend(ll);
                            path.push(ll);
                        }
                        if(!j){
                            exteriorDirection = _ccw(path);
                            paths.push(path);
                        }else if(j == 1){
                            interiorDirection = _ccw(path);
                            if(exteriorDirection == interiorDirection){
                                paths.push(path.reverse());
                            }else{
                                paths.push(path);
                            }
                        }else{
                            if(exteriorDirection == interiorDirection){
                                paths.push(path.reverse());
                            }else{
                                paths.push(path);
                            }
                        }
                    }
                    opts.paths = paths;
                    googleObj.push(new google.maps.Polygon(opts));
                }
                if (geojsonProperties) {
                    for (var k = 0; k < googleObj.length; k++){
                        googleObj[k].set("geojsonProperties", geojsonProperties);
                    }
                }
                break;

            case "GeometryCollection":
                googleObj = [];
                if (!geojsonGeometry.geometries){
                    googleObj = _error("Invalid GeoJSON object: GeometryCollection object missing \"geometries\" member.");
                }else{
                    for (var i = 0; i < geojsonGeometry.geometries.length; i++){
                        googleObj.push(_geometryToGoogleMaps(geojsonGeometry.geometries[i], opts, geojsonProperties || null));
                    }
                }
                break;

            default:
                googleObj = _error("Invalid GeoJSON object: Geometry object must be one of \"Point\", \"LineString\", \"Polygon\" or \"MultiPolygon\".");
        }

        return googleObj;

    };

    var _error = function( message ){

        return {
            type: "Error",
            message: message
        };

    };

    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;
        }
        else{
            isCCW = false;
        }
        return isCCW;
    };

    var obj;

    var opts = options || {};

    switch ( geojson.type ){

        case "FeatureCollection":
            if (!geojson.features){
                obj = _error("Invalid GeoJSON object: FeatureCollection object missing \"features\" member.");
            }else{
                obj = [];
                for (var i = 0; i < geojson.features.length; i++){
                    obj.push(_geometryToGoogleMaps(geojson.features[i].geometry, opts, geojson.features[i].properties));
                }
            }
            break;

        case "GeometryCollection":
            if (!geojson.geometries){
                obj = _error("Invalid GeoJSON object: GeometryCollection object missing \"geometries\" member.");
            }else{
                obj = [];
                for (var i = 0; i < geojson.geometries.length; i++){
                    obj.push(_geometryToGoogleMaps(geojson.geometries[i], opts));
                }
            }
            break;

        case "Feature":
            if (!( geojson.properties && geojson.geometry )){
                obj = _error("Invalid GeoJSON object: Feature object missing \"properties\" or \"geometry\" member.");
            }else{
                obj = _geometryToGoogleMaps(geojson.geometry, opts, geojson.properties);
            }
            break;

        case "Point": case "MultiPoint": case "LineString": case "MultiLineString": case "Polygon": case "MultiPolygon":
            obj = geojson.coordinates
                ? obj = _geometryToGoogleMaps(geojson, opts)
                : _error("Invalid GeoJSON object: Geometry object missing \"coordinates\" member.");
            break;

        default:
            obj = _error("Invalid GeoJSON object: GeoJSON object must be one of \"Point\", \"LineString\", \"Polygon\", \"MultiPolygon\", \"Feature\", \"FeatureCollection\" or \"GeometryCollection\".");

    }

    return obj;

};

Could be the populating of options of Points in GeometryCollection extended?

Right now every Point gets an options of it's GeometryCollection according to this part of code:

var opts = options || {};

isn't it good to extend this options here, like this:

case "Point": case "MultiPoint": case "LineString": case "MultiLineString": case "Polygon": case "MultiPolygon": obj = geojson.coordinates ? { opts.extend(geojson.options); obj = _geometryToGoogleMaps(geojson, opts); } : _error("Invalid GeoJSON object: Geometry object missing \"coordinates\" member."); break;

Please License Under Something Permissive

It would be super fantastic if this has a license file / text block somewhere indicating that it is cool to use it. It would be doubly fantastic if the license was something permissive like BSD / MIT.

Thanks for the software, I appreciate your efforts on our behalf.

A Sample BSD License

Just a suggestion: for GeoJson's linear rings in polygons, remove the last vertex

Hello,

thanks for the script.

While debugging my code, i came to see this in the spec:

"Paths are closed automatically; do not repeat the first vertex of the path as the last vertex."

See:

https://developers.google.com/maps/documentation/javascript/reference#PolygonOptions

The linear rings in polygons in GeoJson have this extra vertex. So it could be removed (go up to length-1), when copying/transforming, like your script does.

                        for (var k = 0; k < geojsonGeometry.coordinates[i][j].length; k++){
                            // the ring: array of coordinates, where first/last coordinate/vertex/point match
                            var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][k][1], geojsonGeometry.coordinates[i][j][k][0]);
                            bounds.extend(ll);
                            path.push(ll);
                        }

Thats all :)

Polygon with hole not showing hole - only boundary

So, the Geojson for the polygon with hole, I'm using looks like this:

{"type": "Polygon", "coordinates": [

[ [ 75.889979740301499, 14.124073402361812 ], [ 79.596655025929664, 14.10023626226131 ], [ 79.554940030753784, 11.871463662864317 ], [ 75.895939025326626, 11.919137943065323 ], [ 75.889979740301499, 14.124073402361812 ] ],

[ [ 77.4240645, 13.0688045 ], [ 77.4356598, 13.0623401 ], [ 77.4349211, 13.0589817 ], [ 77.436768, 13.0515452 ], [ 77.441693, 13.0429089 ], [ 77.4468644, 13.0257554 ], [ 77.4423087, 13.0195174 ], [ 77.4402154, 13.0087206 ], [ 77.4383686, 13.0087206 ], [ 77.4383686, 13.0112399 ], [ 77.4308579, 13.0114798 ], [ 77.4297497, 13.0066811 ], [ 77.4378761, 13.0059614 ], [ 77.4405849, 13.0000828 ], [ 77.4471106, 12.995164 ], [ 77.446495, 12.984726 ], [ 77.4409543, 12.9812466 ], [ 77.4263022, 12.9829263 ], [ 77.4215002, 12.9712881 ], [ 77.4250709, 12.9667286 ], [ 77.4196532, 12.9670884 ], [ 77.4159595, 12.9586893 ], [ 77.4166982, 12.9481298 ], [ 77.4221158, 12.9470499 ], [ 77.4226084, 12.9405699 ], [ 77.4155901, 12.94081 ], [ 77.4123888, 12.9346899 ], [ 77.4215002, 12.9332498 ], [ 77.4189145, 12.9277296 ], [ 77.4216232, 12.9225693 ], [ 77.4080794, 12.9230493 ], [ 77.4068481, 12.9156087 ], [ 77.4095569, 12.9069676 ], [ 77.395389, 12.9089109 ], [ 77.3934272, 12.909248 ], [ 77.3947816, 12.8919652 ], [ 77.3928116, 12.885964 ], [ 77.3935504, 12.8695199 ], [ 77.4021693, 12.8650786 ], [ 77.4035236, 12.8730008 ], [ 77.4093106, 12.8751614 ], [ 77.4162057, 12.8749213 ], [ 77.4153439, 12.8714403 ], [ 77.4216232, 12.8716805 ], [ 77.4279028, 12.8746813 ], [ 77.4307347, 12.8750414 ], [ 77.4302422, 12.8697599 ], [ 77.4189145, 12.8687997 ], [ 77.423224, 12.860037 ], [ 77.4303654, 12.8564358 ], [ 77.4275334, 12.8500736 ], [ 77.4386149, 12.8492333 ], [ 77.4365217, 12.8465923 ], [ 77.4559758, 12.8392693 ], [ 77.4554833, 12.8327867 ], [ 77.4579458, 12.8276245 ], [ 77.4604084, 12.8275044 ], [ 77.4580689, 12.8203011 ], [ 77.4680422, 12.8096157 ], [ 77.4804781, 12.8078147 ], [ 77.4840488, 12.8154986 ], [ 77.4929139, 12.816099 ], [ 77.4951302, 12.822342 ], [ 77.5019022, 12.822222 ], [ 77.5100286, 12.8267841 ], [ 77.5182781, 12.8235426 ], [ 77.5200019, 12.8127373 ], [ 77.5243112, 12.8114166 ], [ 77.5299752, 12.8127373 ], [ 77.5318221, 12.8139379 ], [ 77.5305908, 12.8163391 ], [ 77.5369934, 12.8193406 ], [ 77.5409335, 12.8164592 ], [ 77.5403178, 12.8145382 ], [ 77.5415491, 12.7972489 ], [ 77.5441348, 12.7949676 ], [ 77.5446273, 12.7982095 ], [ 77.5505374, 12.800971 ], [ 77.558048, 12.7996503 ], [ 77.5557087, 12.7889641 ], [ 77.5621441, 12.7879337 ], [ 77.5639582, 12.7876432 ], [ 77.5629732, 12.7850017 ], [ 77.5562012, 12.7819998 ], [ 77.559895, 12.7671099 ], [ 77.5660514, 12.7591843 ], [ 77.5713458, 12.7608655 ], [ 77.5734389, 12.7656689 ], [ 77.5722077, 12.779238 ], [ 77.581196, 12.787163 ], [ 77.5932625, 12.7811592 ], [ 77.5933856, 12.7773168 ], [ 77.6006287, 12.7795859 ], [ 77.6017368, 12.782828 ], [ 77.6097401, 12.7889517 ], [ 77.6149114, 12.7896722 ], [ 77.6168814, 12.7950754 ], [ 77.614542, 12.8004784 ], [ 77.623284, 12.8038402 ], [ 77.6204521, 12.8112842 ], [ 77.628086, 12.8081626 ], [ 77.6335036, 12.8092431 ], [ 77.6347349, 12.8061215 ], [ 77.6386749, 12.8055212 ], [ 77.6375668, 12.7971165 ], [ 77.6397831, 12.7945951 ], [ 77.6472938, 12.7919535 ], [ 77.6477863, 12.7986774 ], [ 77.6490175, 12.799638 ], [ 77.6488945, 12.8042005 ], [ 77.6624384, 12.8044406 ], [ 77.6598528, 12.8141657 ], [ 77.6633003, 12.8114043 ], [ 77.6647779, 12.8171672 ], [ 77.6779525, 12.8145259 ], [ 77.6818925, 12.8231701 ], [ 77.6858326, 12.8246106 ], [ 77.6870639, 12.8361357 ], [ 77.6893694, 12.8417906 ], [ 77.692974, 12.8397373 ], [ 77.6986378, 12.838897 ], [ 77.7073798, 12.8308536 ], [ 77.7177224, 12.8316939 ], [ 77.7215394, 12.8303733 ], [ 77.7236326, 12.8358957 ], [ 77.7264645, 12.8367361 ], [ 77.7225244, 12.8404576 ], [ 77.7258489, 12.8453795 ], [ 77.7224013, 12.8453795 ], [ 77.7195694, 12.8506615 ], [ 77.7205544, 12.852102 ], [ 77.7300352, 12.8515018 ], [ 77.732744, 12.8569036 ], [ 77.7450567, 12.8524621 ], [ 77.7519518, 12.852342 ], [ 77.7534292, 12.8468199 ], [ 77.7686971, 12.8453795 ], [ 77.7718984, 12.8471802 ], [ 77.7718984, 12.8516218 ], [ 77.7683277, 12.8540226 ], [ 77.7686971, 12.8591844 ], [ 77.7542912, 12.8605048 ], [ 77.7541681, 12.8648261 ], [ 77.7487505, 12.867827 ], [ 77.7563844, 12.8693875 ], [ 77.7568769, 12.874789 ], [ 77.7641414, 12.8847514 ], [ 77.7654958, 12.8929131 ], [ 77.7635258, 12.8990341 ], [ 77.7683277, 12.8996343 ], [ 77.7701746, 12.9103158 ], [ 77.7726372, 12.9106758 ], [ 77.7744841, 12.9214769 ], [ 77.7807635, 12.9219569 ], [ 77.784088, 12.9293973 ], [ 77.7779316, 12.9327574 ], [ 77.7767004, 12.9377976 ], [ 77.7760847, 12.9404375 ], [ 77.7833492, 12.9433176 ], [ 77.7839649, 12.9451176 ], [ 77.7728834, 12.9509974 ], [ 77.7752228, 12.9547172 ], [ 77.7750997, 12.9592769 ], [ 77.778301, 12.9643165 ], [ 77.7917219, 12.9645565 ], [ 77.7909831, 12.9679161 ], [ 77.7871662, 12.9683961 ], [ 77.7858118, 12.9715157 ], [ 77.780271, 12.9715157 ], [ 77.7771929, 12.9741553 ], [ 77.7774391, 12.976555 ], [ 77.7817486, 12.9800345 ], [ 77.7887668, 12.9818342 ], [ 77.7964007, 12.9946717 ], [ 77.7936919, 13.0049893 ], [ 77.7891362, 13.0063089 ], [ 77.7906137, 13.0144666 ], [ 77.7988632, 13.0121873 ], [ 77.8018182, 13.0285021 ], [ 77.7913525, 13.0255031 ], [ 77.7835955, 13.0267027 ], [ 77.7813739, 13.0474782 ], [ 77.7746072, 13.0476945 ], [ 77.7741147, 13.0504532 ], [ 77.7702977, 13.0504532 ], [ 77.769559, 13.055491 ], [ 77.7605707, 13.0562107 ], [ 77.7593103, 13.0597652 ], [ 77.7494892, 13.065806 ], [ 77.7363147, 13.0653263 ], [ 77.734714, 13.0728823 ], [ 77.7264645, 13.073482 ], [ 77.7238788, 13.0767203 ], [ 77.7025779, 13.0758807 ], [ 77.6999922, 13.0895529 ], [ 77.695929, 13.0896728 ], [ 77.7013465, 13.1114987 ], [ 77.7047942, 13.1141369 ], [ 77.6907577, 13.1291259 ], [ 77.6922352, 13.1362004 ], [ 77.682385, 13.1364401 ], [ 77.6790606, 13.1282865 ], [ 77.6557896, 13.1262481 ], [ 77.6566515, 13.1333227 ], [ 77.6454469, 13.1375194 ], [ 77.6417531, 13.1340421 ], [ 77.635843, 13.1364401 ], [ 77.6369511, 13.1459126 ], [ 77.6197134, 13.1576625 ], [ 77.6199596, 13.1679732 ], [ 77.6122026, 13.1677335 ], [ 77.6124489, 13.1743273 ], [ 77.600013, 13.172529 ], [ 77.5847453, 13.1742074 ], [ 77.5751414, 13.1772046 ], [ 77.5718169, 13.1825993 ], [ 77.5608586, 13.1827192 ], [ 77.5623361, 13.1755262 ], [ 77.5512547, 13.1664147 ], [ 77.5460834, 13.1685727 ], [ 77.5448521, 13.1728887 ], [ 77.5315544, 13.1720494 ], [ 77.5342632, 13.1635373 ], [ 77.5322931, 13.1592211 ], [ 77.5272449, 13.1543054 ], [ 77.5204729, 13.1576625 ], [ 77.5122234, 13.1569431 ], [ 77.5114847, 13.1465121 ], [ 77.4981868, 13.14891 ], [ 77.4979407, 13.1370398 ], [ 77.4879674, 13.1407568 ], [ 77.4847661, 13.132963 ], [ 77.4771322, 13.1328431 ], [ 77.4771322, 13.1298454 ], [ 77.4793485, 13.1281667 ], [ 77.4800872, 13.1225308 ], [ 77.4819342, 13.1191733 ], [ 77.4779941, 13.1147365 ], [ 77.4736847, 13.1138971 ], [ 77.4743003, 13.1291259 ], [ 77.471099, 13.1304449 ], [ 77.4708527, 13.1335625 ], [ 77.4632189, 13.1357208 ], [ 77.4628495, 13.1260083 ], [ 77.4564469, 13.1286463 ], [ 77.4546, 13.1178543 ], [ 77.45854, 13.1146166 ], [ 77.4594019, 13.0980676 ], [ 77.457555, 13.0948297 ], [ 77.4452423, 13.092671 ], [ 77.4447498, 13.0818774 ], [ 77.4261576, 13.0828368 ], [ 77.4240645, 13.0688045 ]]]}

Why is this not loading as a hole in a polygon?

_ccw function doesn't work correctly...

I have 2 different implementations of CW / CCW checking a polygon that says _CCW is broken.

in this polygon-with-a-hole example, the first (container) polygon returns FALSE when in fact it should be TRUE

POLYGON((12.506438874490113 55.69387403915987,12.506383924458678 55.69387945126558,12.506213385267452 55.69393118376367,12.506056215448675 55.69401519278204,12.505918454950342 55.69412824990123,12.505805397831145 55.694266010399566,12.505721388812773 55.694423180218344,12.50566965631469 55.694593719409575,12.505652188387785 55.69477107424777,12.505652188387785 55.694782297592326,12.50566965631469 55.69495965243052,12.505721388812773 55.69513019162175,12.505805397831145 55.69528736144053,12.50591845495034 55.69542512193886,12.506288781107672 55.6957954480962,12.506287364476293 55.695798284665685,12.506226626676789 55.695954472826,12.506195590101983 55.696119156014994,12.506195309418892 55.69628673806335,12.506225794165529 55.69645152429437,12.506286008426782 55.696607915037234,12.506373906036295 55.69675059591176,12.50638064841556 55.69675956830191,12.506501158182662 55.69689085905994,12.506644965944647 55.6969961168136,12.506806545249868 55.69707129656644,12.506979686696237 55.697113509202715,12.507157736555069 55.69712113251449,12.507333852470138 55.697093873542165,12.50750126640559 55.69703277983276,12.507653544737774 55.696940199183274,12.508073033437034 55.69662497081464,12.508488864506306 55.69639060863607,12.509826195988113 55.695971871005334,12.510830995366488 55.695688712840166,12.51084709380152 55.695684015512036,12.510879201285752 55.69567432470428,12.510895210334953 55.69566933122465,12.511965133638233 55.6953247448608,12.513030154642344 55.6951532398385,12.514088177157936 55.6949828609703,12.516536668569822 55.6949828609703,12.51797341894285 55.695225796423664,12.51895313043089 55.69554132937238,12.519718507195165 55.69588642982222,12.519728341047347 55.69589079396934,12.519748059710187 55.69589940558021,12.519757944520842 55.69590365304395,12.520896991553945 55.69638513255557,12.521900534287525 55.697193119089455,12.521912453941491 55.69720255284616,12.52193644932163 55.69722121973652,12.521948525047804 55.69723045287018,12.523403432003251 55.69832372537399,12.524447852928896 55.69933274669056,12.525400078494183 55.70049542634759,12.525910692858677 55.701142854913094,12.52615587483902 55.701764593324505,12.526176170085762 55.70181206269261,12.526219422482832 55.701905772813255,12.526242379633162 55.701952013565794,12.526609642396016 55.70264185943416,12.526715753728695 55.70335936886895,12.526715753728695 55.70459570345488,12.526610362655404 55.705130147757686,12.526327567771318 55.70584716649138,12.526321927869287 55.705861836606616,12.526310902524104 55.70589127214704,12.526305517080953 55.705906037572234,12.526133856828988 55.706389629079744,12.525962196700053 55.70687321425571,12.525939408094434 55.706947287044976,12.525900222576686 55.70709710440454,12.525873939608504 55.70724971486163,12.52586075019819 55.70740400933815,12.52585744684393 55.70748143792787,12.52585744684393 55.70777158827011,12.525861704840727 55.707859472750116,12.525878696940742 55.70803441844408,12.525912521965695 55.708206902051955,12.525962863056522 55.70837530781752,12.526029248638368 55.70853805818409,12.526111056838134 55.708693628572505,12.526207521309916 55.70884056166269,12.526317738413777 55.70897748104523,12.526440675680753 55.7091031041151,12.526575181484594 55.70921625408653,12.526719995829673 55.70931587101663,12.526873762154136 55.70940102173454,12.527035040037665 55.709470908583015,12.527202318694668 55.709524876890484,12.527374031126767 55.70956242110382,12.527548568801835 55.70958318952412,12.527724296721942 55.70958698760127,12.527899568739487 55.70957377975643,12.528072742977551 55.70954368971531,12.528242197210341 55.70949699934918,12.528406344059613 55.70943414603436,12.528563645864448 55.709355718555145,12.528640396863956 55.70931269418492,12.530185349256534 55.708345517998396,12.53020208022049 55.708334787673586,12.5302353035572 55.708312963806875,12.530251795929951 55.708301870264975,12.531753563020542 55.707267688087306,12.533938584834864 55.70594182650137,12.536306261055369 55.704512409806746,12.541674344768955 55.70158199545186,12.544654640345465 55.70036902039354,12.54730633590419 55.69934164077054,12.549944172178838 55.69859834333275,12.551180554965518 55.69828865572595,12.551193237304688 55.698292229305174,12.5518798828125 55.698485708594845,12.55239486694336 55.698582447880554,12.553081512451172 55.69867918692681,12.553596496582031 55.698775925733635,12.554454803466797 55.69896940262903,12.55514144897461 55.69896940262903,12.555828094482422 55.699066140717555,12.556686401367188 55.699066140717555,12.557544708251953 55.699066140717555,12.558403015136719 55.699066140717555,12.559261322021484 55.699066140717555,12.560977935791016 55.699066140717555,12.562007904052734 55.699066140717555,12.563037872314453 55.699066140717555,12.563896179199219 55.699066140717555,12.564754486083984 55.699066140717555,12.56561279296875 55.699066140717555,12.566299438476562 55.699066140717555,12.566986083984375 55.699066140717555,12.567672729492188 55.69887266430105,12.568359375 55.69887266430105,12.569046020507812 55.698775925733635,12.569732666015625 55.698775925733635,12.570419311523438 55.69867918692681,12.570934295654297 55.698582447880554,12.571449279785156 55.698582447880554,12.571964263916016 55.698485708594845,12.572135925292969 55.698485708594845,12.572479248046875 55.698388969069754,12.572650909423828 55.698388969069754,12.572822570800781 55.698292229305174,12.572994232177734 55.698292229305174,12.573165893554688 55.69819548930122,12.57333755493164 55.698098749057806,12.573680877685547 55.69800200857497,12.5738525390625 55.69790526785271,12.574024200439453 55.697711785689854,12.574195861816406 55.69751830256933,12.574539184570312 55.69732481849102,12.574882507324219 55.69703459057783,12.575011353839168 55.69674413363486,12.576081926851117 55.6968877943849,12.579354646430788 55.697717807421235,12.582464699899433 55.6987325591418,12.584875562134387 55.69981949239784,12.586696267450552 55.70084553940411,12.587733423629272 55.701763986277754,12.588591194605184 55.702569594789814,12.5887421506998 55.70279643166676,12.588793856383091 55.702966882461475,12.588862055538897 55.70313152978837,12.588946064557268 55.70328869960715,12.58904507438544 55.70343687828655,12.589158131504638 55.703574638784886,12.589284147113005 55.70370065439325,12.589421907611339 55.703813711512446,12.589570086290726 55.7039127213406,12.589727256109503 55.70399673035897,12.589891903436376 55.70406492951478,12.590062442627602 55.704116662012865,12.590237231297568 55.704151429640994,12.590414586135765 55.7041688975679,12.590592799118141 55.7041688975679,12.590770153956338 55.704151429640994,12.590944942626304 55.704116662012865,12.59111548181753 55.70406492951478,12.591280129144403 55.70399673035897,12.59143729896318 55.7039127213406,12.591585477642568 55.703813711512446,12.5917232381409 55.70370065439325,12.591849253749269 55.703574638784886,12.591962310868466 55.70343687828655,12.592061320696638 55.70328869960715,12.59214532971501 55.70313152978837,12.592213528870815 55.702966882461475,12.592265261368897 55.70279634327024,12.592300028997021 55.70262155460033,12.592317496923927 55.702444199762134,12.592321874445133 55.702355093270924,12.592321874445133 55.70138778301519,12.592319426073963 55.701321107761714,12.592309645777224 55.70118811639543,12.592302313851654 55.70112180028262,12.592130652474701 55.699960996372305,12.592111014362406 55.69986459163217,12.59206143521069 55.699674468891985,12.592031494171268 55.69958075089193,12.59160267483209 55.69845303385288,12.591463567560368 55.697041931440324,12.591463567560368 55.69327183281125,12.591606015953598 55.692067499183054,12.59205174843018 55.690476306052226,12.592792740109559 55.68872202009229,12.593874652136947 55.68715373455574,12.59502538409782 55.68557829194432,12.596410977459929 55.68392920421166,12.597981637707228 55.682689480535885,12.59962986604016 55.68138848722502,12.600713132054198 55.680690466144554,12.602039684702445 55.67994251270842,12.602383015839393 55.67974892907568,12.602528926152395 55.67964660582483,12.60265207056369 55.679517782996605,12.602747716702611 55.67936741118005,12.602812188941677 55.67920126907975,12.602843009648895 55.67902574144343,12.602838994401774 55.67884757369973,12.602800297504007 55.67867361273512,12.602728406055677 55.678510543771914,12.602722893740323 55.678500767379816,12.602625652506278 55.6783608244023,12.602504002593376 55.678241487931565,12.602362218569391 55.67814695124504,12.602205282479988 55.67808053619857,12.60203870878822 55.678044576502145,12.601926082560535 55.67804177285876,12.601468797171982 55.67758448747021,12.601404816977357 55.677505937834965,12.601264378667445 55.67739071086291,12.601103834155408 55.677305707135716,12.600929594017412 55.67725432087012,12.600748615698848 55.67723860393051,12.600568125702074 55.677259183897604,12.600395331030656 55.67731523900898,12.600237131412204 55.67740453097224,12.599830719895348 55.67769096420438,12.598726973913532 55.678313278151855,12.596967029534358 55.67880941538877,12.594931300453283 55.67916256938345,12.59165410847945 55.679347337129926,12.582116687611709 55.679347337129926,12.5786457885836 55.67925415204033,12.575492670973393 55.67878632691834,12.575474519693937 55.67878382051443,12.57543817030588 55.678779174051826,12.57541997219728 55.67877703399313,12.571937167153804 55.678403008104624,12.569309797728781 55.677754915730155,12.56929729033306 55.67775192422254,12.569272234475497 55.67774611843418,12.569259686013655 55.67774330415343,12.567049010305766 55.677263906558046,12.565951780541411 55.67699876923596,12.56561279296875 55.67661648781943,12.564754486083984 55.67593892728007,12.563552856445312 55.67526135500508,12.563209533691406 55.67506775957343,12.563209533691406 55.6747773676235,12.563209533691406 55.6741965748619,12.563209533691406 55.67361577347794,12.563037872314453 55.67313176573814,12.563037872314453 55.67274455523506,12.5628662109375 55.67264775201051,12.562694549560547 55.67264775201051,12.562522888183594 55.67264775201051,12.562179565429688 55.67264775201051,12.561664581298828 55.67264775201051,12.561149597167969 55.67264775201051,12.560462951660156 55.67264775201051,12.559947967529297 55.67284135822011,12.559432983398438 55.67293816096562,12.558403015136719 55.67332536955261,12.558128357613167 55.673441530835326,12.557373046875 55.67322856776513,12.555313110351562 55.67284135822011,12.552738189697266 55.672454144842874,12.55136489868164 55.67235734089977,12.549991607666016 55.672260536717154,12.548274993896484 55.672163732295054,12.546558380126953 55.672163732295054,12.544841766357422 55.672163732295054,12.543468475341797 55.672163732295054,12.542095184326172 55.67235734089977,12.540721893310547 55.672454144842874,12.539863586425781 55.67274455523506,12.539176940917969 55.67313176573814,12.538318634033203 55.67409977523002,12.537803649902344 55.674970963294655,12.53763198852539 55.6758421319593,12.537288665771484 55.67651969417517,12.537117004394531 55.67729403662324,12.537117004394531 55.67797157369159,12.537117004394531 55.67845552155554,12.537117004394531 55.67884267553576,12.537117004394531 55.67903625108894,12.537117004394531 55.67922982568414,12.537117004394531 55.67932661262249,12.537607836443602 55.67984548635786,12.537396698644486 55.679791378601124,12.537383879049896 55.67978819242842,12.537358194918458 55.679782006690445,12.537345330381608 55.67977900712518,12.535628716612077 55.67939187996777,12.535622747895948 55.67939055499131,12.535610801687307 55.67938794521012,12.535604824194793 55.679386660405385,12.534243499773291 55.679098842558425,12.533397124362873 55.67890796690705,12.53258579816952 55.67872499469385,12.531945504737655 55.67854449317814,12.53190633479189 55.67853438611933,12.53182758404593 55.6785159245685,12.531788003245733 55.67850757007647,12.531310145487597 55.678417762950026,12.531245865800148 55.67838506215836,12.53110448816923 55.67832059566502,12.530958118442406 55.6782684471621,12.530807827579425 55.67822899821037,12.530654715230222 55.6782025374504,12.530499901689101 55.6781892584906,12.53042221069336 55.67818593266704,12.5299072265625 55.67818593266704,12.529829535646655 55.67818925848375,12.529674722263588 55.67820253741624,12.529521610067203 55.67822899812197,12.529371319348353 55.67826844699335,12.529224949753678 55.678320595390986,12.529083572239728 55.67838506175566,12.529014263330765 55.67842032100413,12.528670940576859 55.67861389080949,12.528589854341314 55.67866543733348,12.528433575196848 55.6787768006459,12.528289922666534 55.678904036289026,12.528160501456338 55.67904572294577,12.52804675729776 55.67920027787045,12.52799808672746 55.67928359237914,12.527983901957763 55.67929159935812,12.527920206292611 55.67933110204387,12.527795518948459 55.67941574046984,12.527678275913125 55.679510422398536,12.527569284029243 55.67961449624824,12.527516948349273 55.679668795518715,12.52734528822957 55.67986235959562,12.527295093073752 55.67991895941004,12.527198295856566 55.67999172425183,12.527182318146 55.67999622828778,12.52707993154393 55.6800318041499,12.526880120275706 55.68011488888158,12.526782695609553 55.680162397751154,12.526738507929625 55.68018731022649,12.526391902335043 55.6802361630475,12.525831512213381 55.68031514783889,12.522589774405205 55.68031514783889,12.521466325082368 55.68023597494936,12.520615836330766 55.679996227650264,12.520556373881057 55.67998160817093,12.52043659970996 55.67995640529144,12.52037628798857 55.679945821891295,12.519730823280385 55.67985484526994,12.5192567114914 55.679765745236196,12.519208416091097 55.679758007866134,12.519111479052377 55.679745141792765,12.519062837413959 55.67974001308946,12.506703218273334 55.67877218801141,12.506525041035125 55.67877575716866,12.506350983730623 55.67881401840034,12.506187735284431 55.67888550134875,12.50604156924278 55.6789874589643,12.505918102684683 55.67911597307299,12.505822080360726 55.67926610494968,12.505757192354967 55.67943208511057,12.505725932277077 55.679607535031145,12.505725056110554 55.67961872412384,12.505724491312549 55.67975303852322,12.5057437230252 55.67988597015266,12.506114595474946 55.68156321990616,12.506153203884981 55.681691866971995,12.506210346200959 55.68181342120926,12.506215858273102 55.68182319773849,12.506318177894068 55.681969110596945,12.506446997658749 55.68209225821294,12.50659736709583 55.68218790809266,12.506763507592177 55.68225238446485,12.506939034461688 55.68228320953871,12.507117202305203 55.68227919872392,12.507229757826412 55.68225416415193,12.507547094172033 55.68220943495618,12.509075965880882 55.68220943495618,12.511825548517702 55.682391815530195,12.513217717563665 55.68265345228829,12.51552700465196 55.68321143963002,12.517939279019666 55.68393677876868,12.519343062656413 55.68456991511775,12.519947132496398 55.68504669092839,12.520163567076665 55.68526021960128,12.520226939510863 55.68558175278661,12.520229076430246 55.68559226745016,12.520233474218085 55.68561327082413,12.52023573508654 55.68562375953454,12.52036428278143 55.68620349257109,12.52036428278143 55.6862811460293,12.520191357367247 55.686573585585236,12.519792300373105 55.687023482379495,12.51866334080855 55.68829623972286,12.51765647679794 55.68918808446614,12.51631252683482 55.690029776271885,12.5148712099536 55.690751896958815,12.513045224688419 55.691593952606354,12.511193193250325 55.692353107193355,12.509401201373576 55.69308763679745,12.507831077371735 55.693530095698215,12.507019735378103 55.69371300220837,12.506996332776597 55.69371860450064,12.506949684053088 55.69373042653985,12.506926437931085 55.693736646286794,12.506438874490113 55.69387403915987),(12.566843032738586 55.68139134354458,12.566986083984375 55.68135908300579,12.567672729492188 55.681165518948106,12.568016052246094 55.681165518948106,12.568531036376953 55.68106873656005,12.569217681884766 55.68106873656005,12.569732666015625 55.68106873656005,12.570419311523438 55.68106873656005,12.571277618408203 55.68106873656005,12.572135925292969 55.6812623010967,12.572822570800781 55.68145586467539,12.573509216308594 55.681842988958955,12.57436752319336 55.68213332965707,12.575054168701172 55.682520447235085,12.575912475585938 55.68290756098142,12.57659912109375 55.68329467089607,12.57711410522461 55.68368177697907,12.577629089355469 55.68426242891923,12.578315734863281 55.68464952542314,12.579002380371094 55.685036618095474,12.579517364501953 55.68532693508523,12.57986068725586 55.685423706936234,12.580032348632812 55.685423706936234,12.580032348632812 55.68552047854772,12.580032348632812 55.68571402105231,12.580204010009766 55.68619787312307,12.580204010009766 55.686584950469225,12.580204010009766 55.68716555930441,12.580375671386719 55.687842925383116,12.580375671386719 55.688810570855345,12.580375671386719 55.69016523428713,12.580375671386719 55.69074578996186,12.580375671386719 55.69113282228928,12.580375671386719 55.69132633701626,12.580375671386719 55.69142309402056,12.579689025878906 55.69142309402056,12.578487396240234 55.6912295797725,12.57711410522461 55.69113282228928,12.575770668318132 55.690796272428486,12.575740814208984 55.69074578996186,12.575569152832031 55.69045551320206,12.575225830078125 55.69026199416489,12.574882507324219 55.68997171381322,12.574539184570312 55.68987495321711,12.574195861816406 55.689681431306454,12.5738525390625 55.68948790843797,12.57333755493164 55.689391146644546,12.572994232177734 55.68929438461166,12.572650909423828 55.68919762233932,12.572479248046875 55.68919762233932,12.572135925292969 55.68910085982751,12.57162094116211 55.68900409707626,12.571277618408203 55.68900409707626,12.570934295654297 55.68890733408554,12.570247650146484 55.688810570855345,12.569904327392578 55.688810570855345,12.569217681884766 55.68871380738571,12.568531036376953 55.68871380738571,12.567672729492188 55.68871380738571,12.566814422607422 55.68871380738571,12.565956115722656 55.68871380738571,12.564926147460938 55.68871380738571,12.564067840576172 55.68871380738571,12.5628662109375 55.68871380738571,12.561836242675781 55.68871380738571,12.560462951660156 55.68871380738571,12.55960464477539 55.68871380738571,12.558746337890625 55.68871380738571,12.55788803100586 55.68871380738571,12.557201385498047 55.688810570855345,12.556343078613281 55.68890733408554,12.555656433105469 55.68890733408554,12.554798126220703 55.68900409707626,12.553939819335938 55.68919762233932,12.553081512451172 55.68929438461166,12.55239486694336 55.68929438461166,12.5518798828125 55.689391146644546,12.551021575927734 55.689584669991945,12.550678253173828 55.68977819238151,12.549991607666016 55.68987495321711,12.549476623535156 55.69006847416993,12.548789978027344 55.69026199416489,12.548446655273438 55.69045551320206,12.547989612449573 55.69058432209753,12.553253173828125 55.68929438461166,12.553253173828125 55.68948790843797,12.553253173828125 55.689584669991945,12.553253173828125 55.68977819238151,12.553253173828125 55.68987495321711,12.553253173828125 55.69006847416993,12.553253173828125 55.69026199416489,12.552909851074219 55.69045551320206,12.552738189697266 55.69093930660447,12.55239486694336 55.69132633701626,12.552223205566406 55.69171336359679,12.551536560058594 55.6921971414348,12.551021575927734 55.6924874052642,12.550506591796875 55.69277766693856,12.549991607666016 55.69297117352423,12.549476623535156 55.69316467915212,12.548789978027344 55.69335818382221,12.548103332519531 55.69335818382221,12.547245025634766 55.69335818382221,12.546730041503906 55.69335818382221,12.54587173461914 55.69335818382221,12.545356750488281 55.69335818382221,12.544841766357422 55.69335818382221,12.54415512084961 55.69316467915212,12.543844386367198 55.693047920464764,12.537117004394531 55.69422894298507,12.536602020263672 55.69374519028905,12.535743713378906 55.69297117352423,12.534713745117188 55.69190687545034,12.533683776855469 55.69103606456661,12.532825469970703 55.69006847416993,12.532482147216797 55.689584669991945,12.532310485839844 55.68900409707626,12.532310485839844 55.68871380738571,12.532310485839844 55.68832675111251,12.532310485839844 55.68822998644557,12.532310485839844 55.688036456393256,12.532310485839844 55.68793969100791,12.532482147216797 55.68774615951883,12.532997131347656 55.68755262707189,12.534027099609375 55.68745586048923,12.535400390625 55.68706879176388,12.537460327148438 55.68668171920711,12.540550231933594 55.68629464281882,12.543983459472656 55.68571402105231,12.546103979215873 55.68542939908814,12.547073364257812 55.68552047854772,12.548103332519531 55.68561724991976,12.54913330078125 55.68561724991976,12.550678253173828 55.68561724991976,12.5518798828125 55.68561724991976,12.552909851074219 55.68561724991976,12.553596496582031 55.68561724991976,12.554283142089844 55.68561724991976,12.554454803466797 55.68561724991976,12.55462646484375 55.68561724991976,12.554969787597656 55.68561724991976,12.555313110351562 55.68561724991976,12.555828094482422 55.68561724991976,12.556343078613281 55.68561724991976,12.55685806274414 55.68552047854772,12.557544708251953 55.68552047854772,12.558231353759766 55.685423706936234,12.559089660644531 55.68523016299479,12.559776306152344 55.68513339066485,12.560806274414062 55.684939845286586,12.562007904052734 55.684455977650124,12.5628662109375 55.68426242891923,12.563896179199219 55.68387532858369,12.564582824707031 55.68368177697907,12.565441131591797 55.68319789377665,12.565784454345703 55.683004338819316,12.565956115722656 55.682810782904056,12.56612777709961 55.682810782904056,12.56612777709961 55.682617226030914,12.566299438476562 55.68242366819982,12.566471099853516 55.68223010941078,12.566471099853516 55.681842988958955,12.566814422607422 55.68145586467539,12.566843032738586 55.68139134354458))

v2 for handling Google Maps -> GeoJSON

I wrote a version 2.0 of this utility to handle conversion from Google Maps overlays to GeoJSON (my fork).

List of changes:

  • mounted functions in the google.maps.geojson namespace (google.maps.geojson.fromGeoJSON() instead of new GeoJSON())
  • created google.maps.geojson.toGeoJSON()
  • removed duplicate points in GeoJSON polygons for closing rings when converting to GMaps overlays
  • setup a test suite using QUnit which tests GeoJSON -> GMaps, GMaps -> GeoJSON, and GeoJSON -> GMaps -> GeoJSON

toGeoJSON() is designed to handle the output of fromGeoJSON(), though it only handles a subset because I'm not sure how/if it could handle features and collections. The old interactive test page has a perfect example for this:

 {
  "type": "GeometryCollection",
  "geometries": [
    {
      "type": "Point",
      "coordinates": [-80.66256, 35.04271]
    },{
      "type": "MultiPolygon",
      "coordinates": [
        [
          [
            [-80.661917125299155, 35.042245264120233],
            [-80.662257428469147, 35.042566288770765],
            [-80.662116500253873, 35.042670715828088],
            [-80.661715367137106, 35.042389935257198],
            [-80.661917125299155, 35.042245264120233]
          ]
        ],[
          [
            [-80.661547137566686, 35.042510563404129],
            [-80.661677171806787, 35.042417322902836],
            [-80.662084018102888, 35.042702102858307],
            [-80.662039854197829, 35.042756211162953],
            [-80.662002555672572, 35.042820528162387],
            [-80.661457640151127, 35.042647387136952],
            [-80.661547137566686, 35.042510563404129]
          ]
        ]
      ]
    },{
      "type": "LineString",
      "coordinates": [
        [-80.661983228058659, 35.042968081213758],
        [-80.662076494242413, 35.042749414542243],
        [-80.662196794397431, 35.042626481357232],
        [-80.664238981504525, 35.041175532632963]
      ]
    }
  ]
}

When this is converted to GMaps overlays, you have this:

[
  Marker,
  [
    Polygon,
    Polygon
  ],
  Polyline
]

The problem here is that I can't know if the two Polygons are part of a MultiPolygon or a nested GeometryCollection. It's easy to conceive of more complicated examples. If we can't find a method for generating GeoJSON GeometryCollections such that it always matches the input to fromGeoJSON() then I'd rather not deal with it and just let the user manage the complexity if they're ever unlucky enough to need that functionality.

Event binding doesn't seem to work

Polygons that are overlaid appear as clickable but I can't seem to add click events using the google maps API:

overlay = new GeoJSON( data );
google.maps.event.addListener( overlay, 'click', function( e ) {
   console.log( e );
} );

I can't work out if there's a sub object I need to bind to. Nothing I've tried seems to bind the event.

Why no provide center function ?

Hi.

I know there is an issue about this (#14) but you closed it without explain. This function is really useful in some case and I don't know why you reject it. Any good reason ?

Thanks

Handle GeometryCollection as a geometry member

GeometryCollection is a valid value for any geometry member. We should handle this by wrapping the GeometryCollections geometries' Google Maps equivalents (Marker, Polyline, Polygon) in a array.

var myFeature = {
    "type": "Feature",
    "geometry": {
        "type": "GeometryCollection",
        "geometries": [
            {
                "type": "Point",
                "coordinates": [
                    -80.23569,
                    35.23614
                ]
            },{
                "type": "Point",
                "coordinates": [
                    -83.92465,
                    37.55484
                ]
            }
        ]
    }
}

var myGoogleVectors = new GeoJSON(myFeature);

// returns an array with two google.maps.Markers

package.json for npm

Would really be nice to have that one added as it's most popular and most convenient option:

"dependencies": {
    "geoJSON-to-Google-Maps": "1.0.x"
},

Guess the package.json would look something like this:

{
    "name": "geoJSON-to-Google-Maps",
    "version": "1.0.0",
    "description": "Just a simple utility to convert GeoJSON objects to Google Maps vector objects (Marker, Polyline, Polygon)",
    "author": "Jason Sanford <[email protected]>",
    "dependencies": {
        "express": ">= 1.0.0",
        "optimist": ">= 1.0.0"
    },
    "engine": "node 0.6.x"
}

which would need to be aligned by a registration on the NPM package repo.

Thanks in advance!

invert

hello,

I found a 'bug' in your code, it seems, you invert 0 and 1
for example, here, your code :
var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][1], geojsonGeometry.coordinates[i][j][0]);
but it seems to be better using this (working for me):
var ll = new google.maps.LatLng(geojsonGeometry.coordinates[i][j][0], geojsonGeometry.coordinates[i][j][1]);

'Donut' geometries missing the holes

I've found that the geometries that come through GeoJSON.js seem to be missing any holes - any ideas on how to fix this? When I load the json data up in QGIS it displays fine there, so I know it's not the data. I did see a javascript implementation of a JSON > Google Maps feature elsewhere that supposedly takes into consideration polygons with internal rings like this, but unfortunately my JS knowledge is not sufficient to debug that particular implementation or factor it into your code. It's here if you'd like to take a look:

http://friism.com/drawing-geojson-based-polygons-on-google-maps/comment-page-1#comment-1651

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.