1.0.0 • Published 9 months ago

ngx-bingmaps v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Bing Maps - Angular

A simple and modular library for displaying Bing Maps inside an angular application.

The library is designed to be lightweight, relying on the official Bing Maps V8 Web Control SDK as a dependency. Its purpose is to alleviate the challenges of integrating Bing Maps into your Angular Projects.

Head to the PlayGround for a brief demonstration of the capabilities of ngx-bingmaps.

Table of Contents

Prerequisites

To utilize this library completely, you will need a Bing Maps API key. You can acquire a free API key for testing or development purposes by visiting the Bing Maps Dev Center.

Installation

npm is the easiest and fastest way to get started using ngx-bingmaps

npm install ngx-bingmaps --save

Usage

To incorporate the library into your Angular Project, simply follow the instructions provided below. 1. Add the NgxBingmapsModule into your project's module imports

```typescript
import { NgxBingmapsModule } from 'ngx-bingmaps';

@NgModule({
 // ...
 imports: [
   // ...
   NgxBingmapsModule
 ]
})
```
  1. Use the ngx-bingmaps in your angular components HTML as below.
    <ngx-bingmaps [apiKey]="apiKey" [pushpins]="pushpins"></ngx-bingmaps>
    For apiKey use the key acquired in the Prerequisites section. The pushpins variable represents an array of object of type PushpinModel. For a complete list of properties, kindly refer to the Properties section.

Properties

Defines the input properties of the component.

NameTypeDefaultDescription
apiKeystringnullYour Bing Maps API key.
heightstring"100%"The map defaults to 100% height and width of parent element.
mapTypestring"road"This enumeration is used to specify the type of map style that should be displayed by the map. Such as aerial, birdseye, and road etc. For all available options please refer: Bing Maps V8 Web Control - MapTypeId Enumeration
navigationBarModestring"square"The NavigationBarMode can be used to customize the layout and style of the navigation bar. Such as compact, minified, and square etc. For all available options please refer: Bing Maps V8 Web Control - NavigationBarMode Enumeration
pushpinsarray of type PushpinModel[]Pushpins, are the markers used for marking location(s) on the map.
widthstring"100%"The map defaults to 100% height and width of parent element.

Types

Defines the custom types used by the library.

PushpinModel

Pushpins, sometimes also referred to as markers or MapIcons on other mapping platforms, are one of the primary ways of marking a location on a map. The PushpinModel has the following properties.

NameTypeDefaultDescription
locationobject of type GeolocationModelnullThe geolocation for the pushpin on Map.
optionsobject of type PushpinOptionsModelnullVarious options available for creating personalized pushpins.
infoboxobject of type PushpinInfoboxModelnullVarious options available for creating personalized infoboxes.

GeolocationModel

GeolocationModel represents the coordinate information needed to mark locations on a map. The GeolocationModel consists of two properties: latitude and longitude.

The latitude property is used to represent how far north or south a location is. This value is an angle measured around the center of the earth from the equator towards the poles. A positive value is in the northern hemisphere and a negative value is in the southern hemisphere. This value has a range of -90 to 90 degrees however due to the mathematics involved in representing the spherical globe as a flat 2D map, some calculations approach infinity as you approach polar latitudes. To avoid this, Bing Maps and many other mapping platforms that use the Mercator projection system clip the latitude coordinates to approximately -85 and 85 degrees.

The longitude property stores the angle of horizontal offset from the prime meridian (0 degrees). This property has a value between -180 and 180 degrees.

NameTypeDescription
latitudenumberThe latitude of the location.
longitudenumberThe longitude of the location.

PushpinOptionsModel

The following pushpin option properties can be used to create customized pushpins.

NameTypeDefaultDescription
colorstringnullSpecifies what color to make the default pushpin.
cursorstring"pointer"The css cursor to show when pushpin has mouse events on it.
draggablebooleannullA boolean indicating whether the pushpin can be dragged to a new position with the mouse or by touch.
enableClickedStylebooleannullSpecifies whether to enable the clicked style on the pushpin. To unselect a pushpin, simply click it again. Alternatively, you can disable then re-enable this property.
enableHoverStylebooleannullSpecifies whether to enable the hover style on the pushpin.
iconstringnullDefines the the icon to use for the pushpin. This can be a URL to an Image or SVG file, an image data URI, or an inline SVG string. Tip: When using inline SVG, you can pass in placeholders {color} and {text} in your SVG string. This placeholder will be replaced by the pushpins color or text property value when rendered. Note: SVG’s are converted into a static image before being rendered as a pushpin. As such embedded images should use data URI’s and not links to files as the file will not load before the SVG is rendered. CSS classes are also not supported on SVG’s, however inline styles are.
subTitlestringnullA secondary title label value to display under the pushpin. Uses label collision detection. This label automatically changes color between white and dark grey depending on which map style is selected. Requires the title label to be set.
titlestringnullThe title label value to display under the pushpin. This label automatically changes color between white and dark grey depending on which map style is selected. Pushpin Titles support label collision detection, as described below.
textstringnullA short string of text that is overlaid on top of the pushpin.
visiblebooleantrueA boolean indicating whether to show or hide the pushpin. The default value is true. A value of false indicates that the pushpin is hidden, although it is still an entity on the map.

These options are derived, and subset of Bing Maps V8 Web Control - PushpinOptions Object.

PushpinInfoboxModel

The following infobox option properties can be used to create customized infoboxes.

NameTypeDefaultDescription
closeDelayTimenumber0The number of milliseconds to wait before closing an infobox when the visible option is changed from true to false.
descriptionstringnullThe string displayed inside the infobox.
htmlContentstringnullThe HTML that represents the infobox. Note that some infobox options are ignored if custom HTML is set (title, description, maxHeight, maxWidth, actions, showCloseButton, showPoint). Also, if custom HTML is used to represent the infobox, the infobox is anchored at the top-left corner.
maxHeightnumber126The maximum size that the infobox height can expand to based on it’s content.
maxWidthnumber256The maximum size that the infobox width can expand to based on it’s content.
showCloseButtonbooleantrueA boolean indicating whether to show the close dialog button on the infobox. By default, the close button is displayed as an X in the top right corner of the infobox. This property is ignored if custom HTML is used to represent the infobox.
showPointerbooleantrueA boolean indicating whether to display the infobox with a pointer. In this case the infobox is anchored at the bottom point of the pointer. If this property is set to false, the infobox is anchored at the bottom left corner. This property is ignored if custom HTML is used to represent the infobox.
titlestringnullThe title of the infobox.
visiblebooleantrueA boolean indicating whether to show or hide the infobox. A value of false indicates that the infobox is hidden, although it is still an entity on the map.
zIndexnumbernullThe z-index of the infobox with respect to other items on the map.

These options are derived, and subset of Bing Maps V8 Web Control - InfoboxOptions Object.

Examples

In Progress - Coming Soon

1.0.0

9 months ago

0.0.9

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago