Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Commit

Permalink
Support simple GeometryCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Verheul committed Jan 25, 2012
1 parent 5891c1c commit b4c6a70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demo/index.html
Expand Up @@ -23,7 +23,7 @@ <h1>BootMap demo</h1>
<div id="map2" data-map="map" data-type="json" data-input="#map2_data" style="width: 400px; height: 300px"></div>

<textarea id="map2_data">
{ "type": "Point", "coordinates": [ 4, 40 ] }
{ "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [ 4, 40 ] } ] }
</textarea>

<div id="map3" data-map="map" data-type="json" data-input="#map3_data" style="width: 400px; height: 300px"></div>
Expand Down
13 changes: 9 additions & 4 deletions src/bootmap.js
Expand Up @@ -178,12 +178,15 @@
var json = overlayData.json;
var overlay = null;
var overlayOptions = {
strokeWeight: 3,
fillColor: '#55FF55',
fillOpacity: 0.5,
editable: overlayData.editable

};
if (json.type === "GeometryCollection") {
if (json.geometries.length === 1) {
json = json.geometries[0];
} else {
throw "Bootmap can only handle GeometryCollections of length 1";
}
}
switch(json.type) {
case 'Point':
overlayOptions.position = new google.maps.LatLng(json.coordinates[1], json.coordinates[0]);
Expand All @@ -205,6 +208,8 @@
overlay = new google.maps.Polygon(overlayOptions);
addListenersToPolygon(overlay);
break;
default:
throw "Bootmap cannot handle geometries of type '" + json.type + "'";
}
if (overlay) {
overlay.overlayData = overlayData;
Expand Down

0 comments on commit b4c6a70

Please sign in to comment.