Skip to content

Navigation Menu

Sign up
apneadiving edited this page Apr 9, 2011 · 4 revisions

Data to provide

Valid json to provide should be like:

[
 //first element of the array, describing the first polygon
 [
 //first hash here could optionally contain settings for the current polygon (which won't use defaults then)
 {
 longitude": -80.190262, "latitude": 25.774252,
 "strokeColor": "#FF0000",
 "strokeOpacity": 0.3,
 "strokeWeight": 1,
 "fillColor": "#FF0000",
 "fillOpacity": 0.7
 },
 //other hashes simply contain longitude and latitude
 {"longitude": -66.118292, "latitude": 18.466465},
 {"longitude": -64.75737, "latitude": 32.321384}
 ],
 //second polygon
 [
 // the first hash contains no customization so it will use default display options
 {"longitude": 0, "latitude": 0},
 {"longitude": 10, "latitude": 10},
 {"longitude": -10, "latitude": -10}
 ]
 //add as many array as you want
]

Default display configuration:

strokeColor: "#000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#000",
fillOpacity: 0.35

Display Polygons

<%= gmaps({
 "polygons" => { "data" => @polygons_json }
 })
 %>

Change default configuration for polygons

Simply pass options you want to override in a hash.

<%= gmaps({
 "polygons" => { "data" => @polygons , "options" => { "fillColor" => "#000" } }
 })
 %>

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /