nmaier95 / dealerlocator-base

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modules

utils
debounce

Taken from https://davidwalsh.name/function-debounce

htmlEscapehtmlString
htmlEncodehtmlString

Classes

DealerLocator
GoogleMap
MapsDataService
MapsDataSource

utils

debounce ⇒

Taken from https://davidwalsh.name/function-debounce

Returns: void

Param Type
func function
wait number
immediate boolean

htmlEscape ⇒ htmlString

Param Type
html htmlString

htmlEncode ⇒ htmlString

Param Type
encode htmlString

DealerLocator

Kind: global class

new DealerLocator()

controller-class, providing functionality used by the ui

DealerLocator.module.exports

Kind: static class of DealerLocator

new module.exports(config)

Creates an instance of DealerLocator. !! 'distance' and 'id' (items of key templateVars in mapOptions) are properties which cannot change their name/key !!

Param Type
config defaultConfig

DealerLocator.defaultConfig ⇒ Object

returns default parameters for DealerLocator:constructor overwrite it with your settings in DealerLocator:constructor(config)

mapContainer: required resultEl: required resultsContainer: required apiKey: required computeDistanceBetweenPoints: required mapOptions: required urlGenerator: optional hasCluster: optional mapsDataSource: optional {MapsDataSource} mapsDataService: optional {MapsDataService} googleMap: optional {GoogleMap}

Kind: static property of DealerLocator
Access: public

DealerLocator.setData(data) ⇒

calls MapsDataSource to set data if no urlGenerator is passed

Kind: static method of DealerLocator
Returns: void
Access: public

Param Type
data array

DealerLocator.setRequestOptions(requestOptions) ⇒

set requestOptions used in MapsDataSource to fetch data requestOptions can contain following keys: method, acceptType, body, formData, transformer

Kind: static method of DealerLocator
Returns: void
Access: public

Param Type
requestOptions Object

DealerLocator.initializeMap() ⇒ Promise.<undefined>

load mapsAPI and update views with data afterwards

Kind: static method of DealerLocator
Access: public

DealerLocator.showAll() ⇒ Promise.<undefined>

resets all filters, geolocation/radius + properties and displays all tupels cached or to be loaded

Kind: static method of DealerLocator
Access: public

DealerLocator.searchFor(address, resultRadius) ⇒ Promise.<undefined>

geolocating an address or plz, centers map to result and adds radius-filter as well as showing its results

Kind: static method of DealerLocator
Access: public

Param Type
address string
resultRadius number

DealerLocator.mapIsLoaded() ⇒ boolean

mapsAPI loaded/ready or not

Kind: static method of DealerLocator
Access: public

DealerLocator.getCurrentLocation() ⇒ google.maps.Latlng

get current center of gmap

Kind: static method of DealerLocator
Access: public

DealerLocator.locateUser(resultRadius, zoom) ⇒ Promise.<(undefined|Object)>

locates client on gmap and sets class-prop this.clientLatLong for later calculations to show marker near client sets zoomlevel of gmap

Kind: static method of DealerLocator
Access: public

Param Type
resultRadius number
zoom number

DealerLocator.setMapZoom(zoom) ⇒

set zoom-level of gmap

Kind: static method of DealerLocator
Returns: void
Access: public

Param Type
zoom number

DealerLocator.setMaxResults(max) ⇒

set a limit to the result-set

use it before using updateView() to apply the behaviour set it to undefined if no limit is needed

Kind: static method of DealerLocator
Returns: void
Access: public

Param Type
max number

DealerLocator.updateView() ⇒ Promise.<undefined>

updates map and custom-results views, for example after a filter has been applied

Kind: static method of DealerLocator
Access: public

DealerLocator.closeInfoWindow() ⇒

closes currently opened infowindow on gmap

Kind: static method of DealerLocator
Returns: void
Access: public

DealerLocator.addFilterFor(key, value) ⇒ Promise.<undefined>

add filter for property-key and -value

Kind: static method of DealerLocator
Access: public

Param Type
key string
value any

DealerLocator.removeFilter(key, value) ⇒ Promise

remove previously added filter-option

Kind: static method of DealerLocator
Access: public

Param Type
key string
value any

DealerLocator.addRadiusFilterFor(radius) ⇒ Promise.<undefined>

removes old radius-filter and adds passed radius as new radius-filter

Kind: static method of DealerLocator
Access: public

Param Type
radius number

DealerLocator.removeFilterType(type) ⇒ Promise.<undefined>

reset filter for specific type: radius or property

Kind: static method of DealerLocator
Access: public

Param Type
type string

GoogleMap

Kind: global class

new GoogleMap()

exposing api's to interact with google.map instance

GoogleMap.module.exports

Kind: static class of GoogleMap

new module.exports(apiKey, mapContainer, hasCluster, hasCustomResults, mapsDataService, resultEl, resultsContainer, configOptions)

Param Type
apiKey string
mapContainer string
hasCluster boolean
hasCustomResults boolean
mapsDataService MapsDataService
resultEl string
resultsContainer string
configOptions Object

GoogleMap.clientLatLong

Kind: static property of GoogleMap

Param Type
Object.<(lat|lng), number>

GoogleMap.clientLatLong ⇒ google.maps.LatLng

Kind: static property of GoogleMap

GoogleMap.isLoaded ⇒ boolean

Kind: static property of GoogleMap

GoogleMap.markers ⇒ array.<google.maps.Marker>

Kind: static property of GoogleMap

GoogleMap.load() ⇒

initialize gmap api load and callbacks

Kind: static method of GoogleMap
Returns: void
Access: public

GoogleMap.parseInfoWindow(marker, template) ⇒ Promise

parses data and template into google.maps.infowindow

Kind: static method of GoogleMap
Access: public

Param Type
marker google.maps.Marker
template string

GoogleMap.parseTemplate(templateContainer) ⇒ htmlString

template for popup when clicked on position on gmap !! distance and id are properties which cannot change their name/key !!

Kind: static method of GoogleMap
Access: public

Param Type
templateContainer string
Object.<(properties.<Object>|id)>

GoogleMap.replaceTemplateVar(tmpl, templateVar, delimiters, properties) ⇒ htmlString

Replaces template vars in passed template. Escapes html to prevent xss and tries to replace html encoded templatevars as well

Kind: static method of GoogleMap
Returns: htmlString - tmpl
Access: public

Param Type
tmpl htmlString
templateVar string
delimiters array
properties object

GoogleMap.closeInfoWindow() ⇒

closes currently opened infowindow on gmap

Kind: static method of GoogleMap
Returns: void
Access: public

GoogleMap.setZoom(zoom) ⇒

sets zoom-level of gmap

Kind: static method of GoogleMap
Returns: void
Access: public

Param Type
zoom number

GoogleMap.updateView() ⇒ Promise.<undefined>

Kind: static method of GoogleMap
Access: public

GoogleMap.getMarkers() ⇒ Promise.<array.<google.maps.marker>>

generates marker-objects from a dataSource

Kind: static method of GoogleMap
Access: public

GoogleMap.searchFor(address) ⇒ Promise.<any>

searches by address sets this.clientLatLong to result pos

Kind: static method of GoogleMap
Access: public

Param Type
address string

GoogleMap._geocode(parameters) ⇒ Promise.<Object>

in preparation of reverse geocoding where user gets located on page load, this location is a latLng and has to be transfered into a location/country

resources: https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse?hl=de https://developers.google.com/maps/documentation/geocoding/intro?hl=de#Viewports

{'address': address} | {'location': latlng}

Kind: static method of GoogleMap
Access: public

Param Type
parameters object

MapsDataService

Kind: global class

new MapsDataService()

provides logic for MapsDataSource, primarily filtering data

MapsDataService.module.exports

Kind: static class of MapsDataService

new module.exports(mapsDataSource, computeDistanceBetweenPoints)

Creates an instance of MapsDataService.

Param Type
mapsDataSource MapsDataSource
computeDistanceBetweenPoints function | undefined

MapsDataService.maxResults

Kind: static property of MapsDataService

Param Type
max number

MapsDataService.getItems() ⇒ Promise.<undefined>

returns filtered data

Kind: static method of MapsDataService
Access: public

MapsDataService.setData(data) ⇒

prefills data of maps data source if no urlGenerator is passed

Kind: static method of MapsDataService
Returns: void
Access: public

Param Type
data array

MapsDataService.addFilterFor(propName, propValue) ⇒

add filter-option, does not apply them to data yet

Kind: static method of MapsDataService
Returns: void
Access: public

Param Type
propName string
propValue any

MapsDataService.removeFilterFor(propName, propValue) ⇒

remove a specific previously added filter-option, does not apply to data yet

Kind: static method of MapsDataService
Returns: void
Access: public

Param Type
propName string
propValue any

MapsDataService.addRadiusFilterFor(center, radius) ⇒

add filter for radius search

Kind: static method of MapsDataService
Returns: void
Access: public

Param Type
center number
radius number

MapsDataService.removeFilterType(type) ⇒

remove filter of type "radius" or "property"

Kind: static method of MapsDataService
Returns: void
Access: public

Param Type
type string

MapsDataService.resetFilters() ⇒

reset all previously applied filters

Kind: static method of MapsDataService
Returns: void
Access: public

MapsDataService.ensureDetailsFor(ids) ⇒ Promise.<array>

use to check if tuple/s has/have extended properties already loaded, if not it´ll be loaded

Kind: static method of MapsDataService
Access: public

Param Type
ids any

MapsDataService.hasActiveRadiusFilter() ⇒ boolean

checks if any of the active filters is a radius filter, return true or false

Kind: static method of MapsDataService
Access: public

MapsDataSource

Kind: global class

new MapsDataSource()

loads and caches data for maps

MapsDataSource.module.exports

Kind: static class of MapsDataSource

new module.exports(urlGenerator, requestOptions)

Param Type
urlGenerator function
requestOptions Object

MapsDataSource.data ⇒ null | array

Kind: static property of MapsDataSource
Access: public

MapsDataSource.requestOptions

requestOptions can contain following keys: method, acceptType, body, formData, transformer

Kind: static property of MapsDataSource
Access: public

Param Type
requestOptions Object

MapsDataSource.mergeData(data) ⇒ null | array

Merges the given array into the current data

Kind: static method of MapsDataSource
Access: public

Param Type
data array

MapsDataSource.setData(data) ⇒

Kind: static method of MapsDataSource
Returns: void
Access: public

Param Type
data array

MapsDataSource.fetch() ⇒ Promise.<array>

Fetch all locations. Will use cached data on subsequent calls.

Kind: static method of MapsDataSource
Access: public

MapsDataSource.ensureDetailsFor(ids) ⇒ Promise.<array>

Ensures that all given id's contain all detail information. This may trigger a api request.

Kind: static method of MapsDataSource
Access: public

Param Type
ids array

About

License:Apache License 2.0


Languages

Language:JavaScript 100.0%