type | Object ( geomap style ) |
---|---|
default | { borderRadius: "8px", color: "#7f0000", fillOpacity: .2, height: "8px", opacity: 1, strokeOpacity: 1, strokeWidth: "2px", visibility: "visible", width: "8px" } |
init | $( map or service selector ).geomap( { shapeStyle: { color: "green" } } ); |
get | var shapeStyle = $( map or service selector ).geomap( "option", "shapeStyle" ); |
set | $( map or service selector ).geomap( "option", "shapeStyle", { strokeWidth: "4px" } ); |
The shapeStyle option retrieves or updates the base style of shapes appended to the map.
This differs from the drawStyle option which defines the style of incomplete lines and polygons as they are being drawn.
Two extra color properties, stroke and fill, are not defined by default and use the value of the color property until they are defined individually.
This option changes specific properties of the internal base style. If you send an incomplete style object, only the style properties you reference are updated.
Similar to CSS, you can override this style on a per-shape basis by passing a different style to the append method.
Changing this base style will update how geomap draws existing shapes that do not have their own style. For shapes that do have their own style, changing the base shapeStyle will update any style properties not referenced in the shape-specific style. For example, assume the following:
$( "#map" ).geomap( );
$( "#map" ).geomap( "append", { type: "Point", coordinates: [ -71, 42 ] }, { strokeWidth: "4px" } );
$( "#map" ).geomap( "option", "shapeStyle", { stroke: "#00f" } );
The shape described in the above example will draw with a blue stroke color and a strokeWidth of 4px.
You can also set a base style for a specific service. These are called service-level styles and apply only to service-level shapes. To do this, target a service inside a map instead of the map itself for your call to geomap's shapeStyle option. To expand upon the above example, consider the following additional steps:
$( "#map .osm" ).geomap( "option", "shapeStyle", { width: "16px" } )
$( "#map .osm" ).geomap( "append", { type: "Point", coordinates: [ -70.5, 42.5 ] } );
This second point will:
This is the only option that can be applied to services. All other options require a reference to the original map element.
When called with a second argument to set the shapeStyle, the jQuery UI widget factory returns the original jQuery collection to maintain call chaining.
Please see the style section at the bottom of the geomap widget page for more information about the style object.