Google Maps API V3 API containing several ZipCodes

I have to allow the user to enter several zip codes, extract the latitude and longitude from the database, and then create a huge polygon that spans them.

I am Java encoded and use the Google Maps API V3. I have no problem creating a single email program. But when you add more postal codes, the created polylines go on haymaking and distort the polygon, as shown in the figure below. fussy google map polygon

What do I need to change in my code to make all of these smaller polygons one big? I looked at Google’s answers, and all I could find was to create each polygon in a zip code individually, but it still won’t give me the final result of a larger single polygon.

(, String [] []), html javascript .

javascript API Google API:

function clearHello(coords1){
coords = coords1
var triangleCoords = new Array();
var l = coords.length;
for (var x = 0; x < l; x++){
triangleCoords[x] = new google.maps.LatLng( coords[x][0], coords[x][1]);
}
// Construct the polygon.
bermudaTriangle = new google.maps.Polygon({
paths: triangleCoords,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35
});
bermudaTriangle.setMap(document.map);

? , , , , -, ?

: , - , , , zipcode ? , , . , , , 200 .

+3
3

, . () " Dissolve". , , JavaScript-.

JavaScript

Wicket JavaScript (JSTS) Union/Dissolve .

, Wicket Google (WKT), JSTS union/dissolve WKT.

: .

1) JSTS, , lib lib (javascript.util.js, jsts.js) . jsts .

<script type="text/javascript" src="jsts/javascript.util.js"></script>
<script type="text/javascript" src="jsts/jsts.js"></script>

2) Wicket, wicket.js wicket-gmap3.js . , wicket .

<script type="text/javascript" src="wicket/wicket.js"></script>
<script type="text/javascript" src="wicket/wicket-gmap3.js"></script>

Wicket WKT, JSTS Dissolve.

3) , Wicket, Dissolve JSTS.

, Google polygon1 polygon2. , , .

function DissolveTwoGeometriesWithJSTS(polygon1, polygon2)
{
    // Instantiate Wicket
    var wicket = new Wkt.Wkt();

    wicket.fromObject(polygon1);  // import a Google Polygon
    var wkt1 = wicket.write();    // read the polygon into a WKT object

    wicket.fromObject(polygon2);  // repeat, creating a second WKT ojbect
    var wkt2 = wicket.write();

    // Instantiate JSTS WKTReader and get two JSTS geometry objects
    var wktReader = new jsts.io.WKTReader();
    var geom1 = wktReader.read(wkt1);
    var geom2 = wktReader.read(wkt2);

    // In JSTS, "union" is synonymous with "dissolve"
    var dissolvedGeometry = geom1.union(geom2);

    // Instantiate JSTS WKTWriter and get new geometry WKT
    var wktWriter = new jsts.io.WKTWriter();
    var wkt = wktWriter.write(dissolvedGeometry);

    // Reuse your Wicket object to ingest the new geometry WKT
    wicket.read(wkt);

    // Assemble your new polygon options, I used object notation
    var polyOptions = {
        strokeColor: '#1E90FF',
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: '#1E90FF',
        fillOpacity: 0.35    
    };

    // Let wicket create a Google Polygon with the options you defined above
    var newPoly = wicket.toObject(polyOptions);        

    // Now I'll hide the two original polygons and add the new one.
    polygon1.setMap(null);
    polygon2.setMap(null);

    newPoly.setMap(map);
}

. ..

enter image description here

..

enter image description here

+6

javascript topojason. . php class @phpclasses.org. . , . : - .

0

, GeoJson , , API, - , .:

: www.boundaries-io.com

:

//v1//? = 30044,30043,30045

, .. .

java script: https://developers.google.com/maps/documentation/javascript/datalayer#sample_geojson

... map.data.loadGeoJson("...//v1// = 30044,30042,30045? ''); ...

, zipcode: enter image description here

***** *

0
source

All Articles