Skip to content

Commit addc87e

Browse files
Merge pull request #2 from techthoughts2/dev
added API key parameters
2 parents 6d4ea86 + 94bafeb commit addc87e

34 files changed

+805
-285
lines changed

.github/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.7.0]
9+
10+
- Changed API key(s) from being locally sourced environment variables to parameters
11+
- Added ```GoogleAPIKey``` parameter to all Google Maps functions
12+
- Added ```BingMapsAPIKey``` parameter to all Bing Maps functions
13+
814
## [0.6.0]
915

1016
- Initial release.

README.md

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ Both of these Map API keys are *easy to create* and have *no cost* pricing tiers
5454
* [How to get a Google Maps API Key](docs/GoogleMapsAPI.md#how-to-get-a-google-maps-api-key)
5555
* [How to get a Bing Maps API Key](docs/BingMapsAPI.md#how-to-get-a-bing-maps-api-key)
5656

57-
```powershell
58-
# Set your API Keys in the pwshPlaces.psm1 file
59-
# using the appropriate variable names:
60-
61-
$env:GoogleAPIKey = 'yourGoogleAPIKey'
62-
$env:BingAPIKey = 'yourBingAPIKey'
63-
```
64-
65-
If you don't want to adjust the ```.psm1``` then simply ensure that these environment variables are populated in your current session.
66-
6757
### Install pwshPlaces
6858

6959
```powershell
@@ -76,50 +66,50 @@ Install-Module -Name pwshPlaces -Repository PSGallery -Scope CurrentUser
7666
```powershell
7767
######################################################################################
7868
# Google Maps
79-
$env:GoogleAPIKey = 'yourGoogleAPIKey'
69+
$googleAPIKey = 'yourGoogleAPIKey'
8070
######################################################################################
8171
# I want to find a specific place
82-
Find-GMapPlace -Query "Krause's cafe"
83-
Find-GMapPlace -Query '+18306252807'
84-
Find-GMapPlace -Query 'cafe' -PointLatitude '29.7049806' -PointLongitude '-98.068343'
72+
Find-GMapPlace -Query "Krause's cafe" -GoogleAPIKey $googleAPIKey
73+
Find-GMapPlace -Query '+18306252807' -GoogleAPIKey $googleAPIKey
74+
Find-GMapPlace -Query 'cafe' -PointLatitude '29.7049806' -PointLongitude '-98.068343' -GoogleAPIKey $googleAPIKey
8575
#-------------------------------------------------------------------------------------
8676
# I want to search for a type of place
87-
Search-GMapText -Query "Cupcakes" -Type bakery -AllSearchResults
88-
Search-GMapText -Query "italian restaurants in New York" -MinPrice 4
77+
Search-GMapText -Query "Cupcakes" -Type bakery -AllSearchResults -GoogleAPIKey $googleAPIKey
78+
Search-GMapText -Query "italian restaurants in New York" -MinPrice 4 -GoogleAPIKey $googleAPIKey
8979
#-------------------------------------------------------------------------------------
9080
# I want to search for nearby places
91-
Search-GMapNearbyPlace -Latitude '29.7049806' -Longitude '-98.068343' -Radius 5000
92-
Search-GMapNearbyPlace -Latitude '29.7049806' -Longitude '-98.068343' -Radius 10000 -RankByProminence -Keyword 'butcher' -Type store
81+
Search-GMapNearbyPlace -Latitude '29.7049806' -Longitude '-98.068343' -Radius 5000 -GoogleAPIKey $googleAPIKey
82+
Search-GMapNearbyPlace -Latitude '29.7049806' -Longitude '-98.068343' -Radius 10000 -RankByProminence -Keyword 'butcher' -Type store -GoogleAPIKey $googleAPIKey
9383
#-------------------------------------------------------------------------------------
9484
# I want to get very detailed information about a place - place ID retrieved from other commands
95-
Get-GMapPlaceDetail -PlaceID 'ChIJf9Yxhme9XIYRkXo-Bl62Q10' -Contact -Atmosphere
85+
Get-GMapPlaceDetail -PlaceID 'ChIJf9Yxhme9XIYRkXo-Bl62Q10' -Contact -Atmosphere -GoogleAPIKey $googleAPIKey
9686
#-------------------------------------------------------------------------------------
9787
# I want to GeoCode an address
98-
Invoke-GMapGeoCode -Address '148 S Castell Ave, New Braunfels, TX 78130, United States'
88+
Invoke-GMapGeoCode -Address '148 S Castell Ave, New Braunfels, TX 78130, United States' -GoogleAPIKey $googleAPIKey
9989
#-------------------------------------------------------------------------------------
10090
# I want to reverse GeoCode a location
101-
Invoke-GMapGeoCode -Latitude '29.7012853' -Longitude '-98.1250235'
91+
Invoke-GMapGeoCode -Latitude '29.7012853' -Longitude '-98.1250235' -GoogleAPIKey $googleAPIKey
10292
######################################################################################
10393
# Bing Maps
104-
$env:BingAPIKey = 'yourBingAPIKey'
94+
$bingAPIKey = 'yourBingAPIKey'
10595
######################################################################################
10696
# I want to find a specific place
107-
Find-BingPlace -Query "Krause's cafe"
108-
Find-BingPlace -Query 'cafe' -PointLatitude '29.7049806' -PointLongitude '-98.068343'
97+
Find-BingPlace -Query "Krause's cafe" -BingMapsAPIKey $bingAPIKey
98+
Find-BingPlace -Query 'cafe' -PointLatitude '29.7049806' -PointLongitude '-98.068343' -BingMapsAPIKey $bingAPIKey
10999
#-------------------------------------------------------------------------------------
110100
# I want to search for nearby places
111-
Search-BingNearbyPlace -Type Attractions
112-
Search-BingNearbyPlace -Type CafeRestaurants -PointLatitude '29.7049806' -PointLongitude '-98.068343'
101+
Search-BingNearbyPlace -Type Attractions -BingMapsAPIKey $bingAPIKey
102+
Search-BingNearbyPlace -Type CafeRestaurants -PointLatitude '29.7049806' -PointLongitude '-98.068343' -BingMapsAPIKey $bingAPIKey
113103
#-------------------------------------------------------------------------------------
114104
# I want to GeoCode an address
115-
Invoke-BingGeoCode -AddressLine '148 S Castell Ave' -City 'New Braunfels' -State TX -PostalCode 78130
105+
Invoke-BingGeoCode -AddressLine '148 S Castell Ave' -City 'New Braunfels' -State TX -PostalCode 78130 -BingMapsAPIKey $bingAPIKey
116106
#-------------------------------------------------------------------------------------
117107
# I want to reverse GeoCode a location
118-
Invoke-BingGeoCode -Latitude '29.7030' -Longitude '-98.1245'
108+
Invoke-BingGeoCode -Latitude '29.7030' -Longitude '-98.1245' -BingMapsAPIKey $bingAPIKey
119109
#-------------------------------------------------------------------------------------
120110
# I want to determine the Time Zone of a specific place
121-
Find-BingTimeZone -Query 'New Braunfels, TX'
122-
Find-BingTimeZone -PointLatitude 29.70 -PointLongitude -98.11
111+
Find-BingTimeZone -Query 'New Braunfels, TX' -BingMapsAPIKey $bingAPIKey
112+
Find-BingTimeZone -PointLatitude 29.70 -PointLongitude -98.11 -BingMapsAPIKey $bingAPIKey
123113
#-------------------------------------------------------------------------------------
124114
```
125115

docs/Find-BingPlace.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ Returns a list of business entities centered around a location or a geographic r
1515
### textquery (Default)
1616
```
1717
Find-BingPlace -Query <String> [-RegionBias <ccTLD>] [-Language <languages>] [-MaxResults <Int32>]
18-
[<CommonParameters>]
18+
-BingMapsAPIKey <String> [<CommonParameters>]
1919
```
2020

2121
### Rectangle
2222
```
2323
Find-BingPlace [-Query <String>] -SouthLatitude <String> -WestLongitude <String> -NorthLatitude <String>
2424
-EastLongitude <String> [-RegionBias <ccTLD>] [-Language <languages>] [-MaxResults <Int32>]
25-
[<CommonParameters>]
25+
-BingMapsAPIKey <String> [<CommonParameters>]
2626
```
2727

2828
### Circle
2929
```
3030
Find-BingPlace [-Query <String>] [-CircleLatitude <String>] [-CircleLongitude <String>]
3131
[-CircleRadius <String>] [-RegionBias <ccTLD>] [-Language <languages>] [-MaxResults <Int32>]
32-
[<CommonParameters>]
32+
-BingMapsAPIKey <String> [<CommonParameters>]
3333
```
3434

3535
### Point
3636
```
3737
Find-BingPlace [-Query <String>] [-PointLatitude <String>] [-PointLongitude <String>] [-RegionBias <ccTLD>]
38-
[-Language <languages>] [-MaxResults <Int32>] [<CommonParameters>]
38+
[-Language <languages>] [-MaxResults <Int32>] -BingMapsAPIKey <String> [<CommonParameters>]
3939
```
4040

4141
## DESCRIPTION
@@ -48,42 +48,42 @@ Location bias and language can be controlled via parameters.
4848

4949
### EXAMPLE 1
5050
```
51-
Find-BingPlace -Query "Krause's cafe"
51+
Find-BingPlace -Query "Krause's cafe" -BingMapsAPIKey $bingAPIKey
5252
```
5353

5454
Returns place information for the query location biased by IP.
5555

5656
### EXAMPLE 2
5757
```
58-
Find-BingPlace -Query "Krause's cafe" -Language es
58+
Find-BingPlace -Query "Krause's cafe" -Language es -BingMapsAPIKey $bingAPIKey
5959
```
6060

6161
Returns place information for the query location biased by IP and returns a few portions of the results in Spanish.
6262

6363
### EXAMPLE 3
6464
```
65-
Find-BingPlace -Query 'cafe' -PointLatitude '29.7049806' -PointLongitude '-98.068343'
65+
Find-BingPlace -Query 'cafe' -PointLatitude '29.7049806' -PointLongitude '-98.068343' -BingMapsAPIKey $bingAPIKey
6666
```
6767

6868
Returns place information for the query location biased by provided lat/long point.
6969

7070
### EXAMPLE 4
7171
```
72-
Find-BingPlace -Query 'cafe' -CircleLatitude '29.7049806' -CircleLongitude '-98.068343' -CircleRadius '5000'
72+
Find-BingPlace -Query 'cafe' -CircleLatitude '29.7049806' -CircleLongitude '-98.068343' -CircleRadius '5000' -BingMapsAPIKey $bingAPIKey
7373
```
7474

7575
Returns place information for the query location biased by circle lat/long/radius.
7676

7777
### EXAMPLE 5
7878
```
79-
Find-BingPlace -Query 'cafe' -SouthLatitude '39.8592387' -WestLongitude '-75.295486' -NorthLatitude '40.0381942' -EastLongitude '-75.0064087'
79+
Find-BingPlace -Query 'cafe' -SouthLatitude '39.8592387' -WestLongitude '-75.295486' -NorthLatitude '40.0381942' -EastLongitude '-75.0064087' -BingMapsAPIKey $bingAPIKey
8080
```
8181

8282
Returns place information for the query location biased by rectangular two lat/lng pairs in decimal degrees, representing the south/west and north/east points of a rectangle.
8383

8484
### EXAMPLE 6
8585
```
86-
Find-BingPlace -Query 'cafe' -PointLatitude '29.7049806' -PointLongitude '-98.068343' -Language en -MaxResults 20
86+
Find-BingPlace -Query 'cafe' -PointLatitude '29.7049806' -PointLongitude '-98.068343' -Language en -MaxResults 20 -BingMapsAPIKey $bingAPIKey
8787
```
8888

8989
Returns place information for the query location biased by provided lat/long point with a maximum of 20 results in English.
@@ -96,6 +96,7 @@ $findBingPlaceSplat = @{
9696
PointLongitude = '-98.068343'
9797
Language = 'en'
9898
MaxResults = 20
99+
BingMapsAPIKey = $bingAPIKey
99100
}
100101
Find-BingPlace @findBingPlaceSplat
101102
```
@@ -313,6 +314,21 @@ Accept pipeline input: False
313314
Accept wildcard characters: False
314315
```
315316
317+
### -BingMapsAPIKey
318+
Bing Maps API Key
319+
320+
```yaml
321+
Type: String
322+
Parameter Sets: (All)
323+
Aliases:
324+
325+
Required: True
326+
Position: Named
327+
Default value: None
328+
Accept pipeline input: False
329+
Accept wildcard characters: False
330+
```
331+
316332
### CommonParameters
317333
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
318334
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
@@ -328,6 +344,9 @@ Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
328344
Example:
329345
https://dev.virtualearth.net/REST/v1/LocalSearch/?query={query}&userLocation={point}&key={BingMapsAPIKey}
330346
347+
How to get a Bing Maps API Key:
348+
https://github.com/techthoughts2/pwshPlaces/blob/main/docs/BingMapsAPI.md#how-to-get-a-bing-maps-api-key
349+
331350
## RELATED LINKS
332351
333352
[https://github.com/techthoughts2/pwshPlaces/blob/master/docs/Find-BingPlace.md](https://github.com/techthoughts2/pwshPlaces/blob/master/docs/Find-BingPlace.md)

docs/Find-BingTimeZone.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ Retrieve time zone information for any point on Earth
1414

1515
### textquery
1616
```
17-
Find-BingTimeZone -Query <String> [-RegionBias <ccTLD>] [-Language <languages>] [<CommonParameters>]
17+
Find-BingTimeZone -Query <String> [-RegionBias <ccTLD>] [-Language <languages>] -BingMapsAPIKey <String>
18+
[<CommonParameters>]
1819
```
1920

2021
### Point
2122
```
2223
Find-BingTimeZone -PointLatitude <String> -PointLongitude <String> [-RegionBias <ccTLD>]
23-
[-Language <languages>] [<CommonParameters>]
24+
[-Language <languages>] -BingMapsAPIKey <String> [<CommonParameters>]
2425
```
2526

2627
## DESCRIPTION
@@ -30,14 +31,14 @@ Given a pair of coordinates or a place name query the Time Zone API will return
3031

3132
### EXAMPLE 1
3233
```
33-
Find-BingTimeZone -Query 'New Braunfels, TX'
34+
Find-BingTimeZone -Query 'New Braunfels, TX' -BingMapsAPIKey $bingAPIKey
3435
```
3536

3637
Returns Time Zone information for matches found for the provided query.
3738

3839
### EXAMPLE 2
3940
```
40-
Find-BingTimeZone -PointLatitude 29.70 -PointLongitude -98.11
41+
Find-BingTimeZone -PointLatitude 29.70 -PointLongitude -98.11 -BingMapsAPIKey $bingAPIKey
4142
```
4243

4344
Returns Time Zone information for the provided coordinates.
@@ -121,6 +122,21 @@ Accept pipeline input: False
121122
Accept wildcard characters: False
122123
```
123124
125+
### -BingMapsAPIKey
126+
Bing Maps API Key
127+
128+
```yaml
129+
Type: String
130+
Parameter Sets: (All)
131+
Aliases:
132+
133+
Required: True
134+
Position: Named
135+
Default value: None
136+
Accept pipeline input: False
137+
Accept wildcard characters: False
138+
```
139+
124140
### CommonParameters
125141
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
126142
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
@@ -136,6 +152,9 @@ Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
136152
Example:
137153
https://dev.virtualearth.net/REST/v1/TimeZone/{point}?datetime={datetime_utc}&key={BingMapsAPIKey}
138154
155+
How to get a Bing Maps API Key:
156+
https://github.com/techthoughts2/pwshPlaces/blob/main/docs/BingMapsAPI.md#how-to-get-a-bing-maps-api-key
157+
139158
## RELATED LINKS
140159
141160
[https://github.com/techthoughts2/pwshPlaces/blob/master/docs/Find-BingTimeZone.md](https://github.com/techthoughts2/pwshPlaces/blob/master/docs/Find-BingTimeZone.md)

0 commit comments

Comments
 (0)