-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove generated code from repository and other maintenance
- Loading branch information
1 parent
b357359
commit 3b961e8
Showing
15 changed files
with
127 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/node_modules | ||
/dist | ||
/.env | ||
/examples/lib/*d.ts | ||
/examples/examples.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// title: multiple markers / single selection (alternative w/ 'style objects') | ||
import {Attributes, Marker} from './lib/marker'; | ||
|
||
function rnd(min: number, max: number) { | ||
return min + Math.random() * (max - min); | ||
} | ||
|
||
export default (map: google.maps.Map) => { | ||
const markers: Marker[] = []; | ||
const bounds = new google.maps.LatLngBounds(); | ||
|
||
// | ||
|
||
const defaultStyle: Partial<Attributes> = { | ||
color: '#4285F4', | ||
scale: ({marker}) => (marker.hovered ? 1.3 : 1.2) | ||
}; | ||
const selectedStyle = {...defaultStyle, color: '#DB4437'}; | ||
|
||
// | ||
|
||
let selectedMarker: Marker | null = null; | ||
|
||
// create a couple of random markers | ||
for (let i = 0; i < 10; i++) { | ||
const position = {lat: rnd(53.5, 53.6), lng: rnd(9.9, 10.1)}; | ||
bounds.extend(position); | ||
|
||
const marker = new Marker({ | ||
map, | ||
position, | ||
...defaultStyle | ||
}); | ||
|
||
marker.addListener('click', () => { | ||
if (selectedMarker !== null) { | ||
selectedMarker.setAttributes(defaultStyle); | ||
} | ||
|
||
const marker = markers[i]; | ||
marker.setAttributes(selectedStyle); | ||
selectedMarker = marker; | ||
}); | ||
|
||
markers.push(marker); | ||
} | ||
|
||
map.fitBounds(bounds); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// title: basic marker collection | ||
|
||
import {CollisionBehavior, Marker} from './lib/marker'; | ||
import {MarkerCollection} from './lib/marker-collection'; | ||
import {MaterialIcons} from './lib/icons'; | ||
|
||
function rnd(min: number, max: number) { | ||
return min + Math.random() * (max - min); | ||
} | ||
|
||
type MyData = { | ||
id: number; | ||
position: google.maps.LatLngLiteral; | ||
category: string; | ||
}; | ||
|
||
const categories = ['a', 'b', 'c']; | ||
const categoryIcons: {[c: string]: string} = { | ||
a: 'restaurant', | ||
b: 'nightlife', | ||
c: 'person' | ||
}; | ||
|
||
async function loadData(): Promise<MyData[]> { | ||
const data = []; | ||
for (let i = 0; i < 50; i++) { | ||
const position = {lat: rnd(53.5, 53.6), lng: rnd(9.9, 10.1)}; | ||
const category = categories[Math.floor(Math.random() * 3)]; | ||
|
||
data.push({ | ||
id: i, | ||
position, | ||
category | ||
}); | ||
} | ||
|
||
return data; | ||
} | ||
|
||
export default async (map: google.maps.Map) => { | ||
Marker.registerIconProvider(MaterialIcons()); | ||
|
||
const data = await loadData(); | ||
const markers = new MarkerCollection(data, { | ||
position: ({data}) => data.position, | ||
scale: 1.4, | ||
color: ({marker}) => (marker.hovered ? '#ffcc22' : '#dd9222'), | ||
icon: ({data}) => categoryIcons[data.category], | ||
collisionBehavior: CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY | ||
}); | ||
|
||
markers.map = map; | ||
map.moveCamera({ | ||
center: {lat: 53.55, lng: 10}, | ||
zoom: 11, | ||
heading: 0, | ||
tilt: 0 | ||
}); | ||
|
||
return () => { | ||
markers.map = null; | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters