From 6c6399ea925cd6f5672aff869aaa7a503a357ee6 Mon Sep 17 00:00:00 2001 From: Grant Hutchins Date: Mon, 28 Nov 2016 10:29:09 -0600 Subject: [PATCH] google-maps: Use correct type for callback argument Fixes https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11509 Also, update tests to be more realistic. Signed-off-by: Jon West Signed-off-by: Grant Hutchins --- google-maps/google-maps-tests.ts | 33 +++++++++++++++++++++++++------- google-maps/index.d.ts | 3 ++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/google-maps/google-maps-tests.ts b/google-maps/google-maps-tests.ts index c723a9ded3..3f55b1de55 100644 --- a/google-maps/google-maps-tests.ts +++ b/google-maps/google-maps-tests.ts @@ -1,9 +1,19 @@ import GoogleMapsLoader = require('google-maps'); - -GoogleMapsLoader.load(function(google) { - var loadedMap = google.maps.Map; + +GoogleMapsLoader.load(function (google) { + var uluru = {lat: -25.363, lng: 131.044}; + + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 4, + center: uluru + }); + + var marker = new google.maps.Marker({ + position: uluru, + map: map + }); }); GoogleMapsLoader.KEY = 'qwertyuiopasdfghjklzxcvbnm'; @@ -17,11 +27,20 @@ GoogleMapsLoader.LIBRARIES = ['geometry', 'places']; GoogleMapsLoader.LANGUAGE = 'fr'; -GoogleMapsLoader.release(function() { +GoogleMapsLoader.release(function () { console.log('No google maps api around'); }); -GoogleMapsLoader.onLoad(function(google) { - var loadedMap = google.maps.Map; - console.log('I just loaded google maps api'); +GoogleMapsLoader.onLoad(function (google) { + var uluru = {lat: -25.363, lng: 131.044}; + + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 4, + center: uluru + }); + + var marker = new google.maps.Marker({ + position: uluru, + map: map + }); }); diff --git a/google-maps/index.d.ts b/google-maps/index.d.ts index f5c28f1581..4167de72e5 100644 --- a/google-maps/index.d.ts +++ b/google-maps/index.d.ts @@ -6,8 +6,9 @@ /// declare namespace GoogleMapsLoader { + type google = { maps: typeof google.maps }; interface CallBack { - (google: { maps: { Map: google.maps.Map } }): void; + (google: google): void; } export var KEY: string; export var CLIENT: string;