Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
measuretool-googlemaps-v3
Advanced tools
Readme
A handy measurement widget for Google Maps API v3. The functionalities are implemented as close as to what current Google Maps offers.
Array<Segment>
to the MeasureResult
. Example see [#31].(https://github.com/zhenyanghua/MeasureTool-GoogleMaps-V3/issues/31)Make sure the geometry
library is referenced in the Google Maps JavaScript API loading script.
libraries=geometry
To create the measurement widget, pass in a Google Map instance.
var measureTool = new MeasureTool(map);
MeasureToolOptions
You could also pass in a MeasureToolOptions
as the second argument to customize to your preference.
var measureTool = new MeasureTool(map, {
showSegmentLength: true,
unit: MeasureTool.UnitTypeId.IMPERIAL // or just use 'imperial'
});
The MeasureTool
comes with a context menu out of box for saving your time to create your own. However, if you'd like to bind the MeasureTool
to your own UI, you could specify contextMenu
to false
when constructing the MeasureTool
. The MeasureTool
exposes two public methods start()
and end()
to start and end measuring. For example,
<button onclick="measureTool.start()">start</button>
<button onclick="measureTool.end()">end</button>
var measureTool = new MeasureTool(map, {
contextMenu: false
// some other options...
});
Constructor | Description |
---|---|
MeasureTool(map:google.maps.Map , opts?:MeasureToolOptions ) | Creates a new measure tool for the google.maps.Map instance. |
Methods | Description |
---|---|
addListener(eventName: string , handler:Function ) | Return Value: None - addes the given listener function to the given event name. |
end() | Return Value: None - ends measuring. |
removeListener(eventName: string ) | Return Value: None - removes the given listener. |
start() | Return Value: None - starts measuring. |
setOption(option: string , value: string ) | Return Value: None - updates a confirguration option and re-generates the drawn shape. |
Properties | Description |
---|---|
area | Type: number - the total area of the enclosed polygon, the unit is m² for metric unit and ft² for imperial unit. |
areaText | Type: string - the formatted total area with unit of the enclosed polygon. |
length | Type: number - the total length of the path drawn, the unit is m for metric unit and ft for imperial unit. |
lengthText | Type: string - the formatted total length with unit of the path drawn. |
Events | Description |
---|---|
measure_change | Arguments: MeasureEvent - This event is fired when a measure step is completed |
measure_end | Arguments: MeasureEvent - This event is fired when the user ends measuring |
measure_start | Arguments: None - This event is fired when the user starts measuring |
Properties | Description |
---|---|
showSegmentLength | Type: boolean - display segment length along the path. Enabled by default. |
tooltip | Type: boolean - display tooltip when hover the drawing path. Enabled by default. |
unit | Type: UnitTypeId - the unit type to use for the measured length and area. Defaults to MeasureTool.UnitTypeId.METRIC . |
Properties | Description |
---|---|
result | Type: MeasureResult - the result of the measuring. |
Properties | Description |
---|---|
area | Type: number - the total area of the enclosed polygon, the unit is m² for metric unit and ft² for imperial unit. |
areaText | Type: string - the formatted total area with unit of the enclosed polygon. |
length | Type: number - the total length of the path drawn, the unit is m for metric unit and ft for imperial unit. |
lengthText | Type: string - the formatted total length with unit of the path drawn. |
segments | Type: Array<Segment> - an array of all segments in measurement. |
Properties | Description |
---|---|
start | Type: SegmentPoint - the latitude and longitude of the segment start location. |
end | Type: SegmentPoint - the latitude and longitude of the segment end location. |
length | Type: SegmentLength - the length of the segment. |
Properties | Description |
---|---|
lat | Type: number - the latitude of a segment point. |
lng | Type: number - the longitude of a segment point. |
Properties | Description |
---|---|
text | Type: string - the formatted length of a segment. |
value | Type: number - the length of a segment, the unit is m for metric unit and ft for imperial unit. |
Identifiers for common UnitType. Specify these by value, or by using the constant's name. For example, 'metric'
or MeasureTool.UnitTypeId.METRIC
.
Constant | Description |
---|---|
IMPERIAL | This unit type shows measured length in US foot (ft) and mile (mi), and area in US square foot (ft²) and square mile (mi²). |
METRIC | This unit type shows measured length in meter (m) and kilometer (km), and area in square meter (m²) and square kilometer (km²). |
FAQs
A handy measurement widget for Google Maps API v3. The functionalities are implemented as close as to what current Google Maps offers.
We found that measuretool-googlemaps-v3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).