DefinitelyTyped/googlemaps/google.maps-tests.ts
Andy 5bce8fab2e Merge more from types-2.0 to `master (#13770)
* Add memoizee definitions

* Fix common issues, added doc

* Removed blank line

* fix test

* Fix test methods

* Fix check style

* Fix check style

* Fixing semver header

* Fixing semver header

* `memoizee`: Clean up types

* Types 2.0 - Fix JS-quantities (#12739)

* Enable strict null checking per readme FAQ.

* Add tslint.json.

* Improve test file with project spec.

* Fix js-quantities d.ts, with adjustment of test.

* Add trailing newline to tslint.

* Simplify functional interface per linter.

* js-quantities: add readme examples to tests

* js-quantities: fix & clean declaration

* d3-selection: Mark before param of insert() as optional (#13090)

Selection<etc>.insert functions perfectly well without a `before` selector -- it does so in many d3 official examples.

This corrects the type signature to mark it as optional.

* [react-intl] bugfix for #12716 (#12906)

* fix for issue introduced in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12716

* injectIntl is now usable as class decorator

* fixed test

* use inferface instead of type

* format document

* fix chai-json-schema styling (#13537)

* googlemaps: Allow Marker.setAnimation(null) and Marker.setMap(null) (#13240)

* googlemaps: Allow Marker.setAnimation(null)

 * Also, turn on strictNullChecks
 * Allow new google.maps.Map(null) since it's technically possible with Google's example code from the docs

Signed-off-by: Iqbal Yusuf <iyusuf@corelogic.com>

* googlemaps: Allow Marker.setMap(null)

 * Also, add more test code from the Google Maps API documentation

Signed-off-by: Grant Hutchins <ghutchins@pivotal.io>

* Added the brand property to the StripeCardData and fix style issues, lint (#13084)

* Add the "brand" field to StipeCardData
Added the StipeCardDataBrand type.
Added the `brand` property to the `StripeCardData` declaration with the type
`'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'`
Reference: https://stripe.com/docs/api#card_object

* Run linter, fix issues. set --strictNullChecks.
Unsure about ambient declaration:
Removed as it seemed to be in error:
  1. case was not correct
  2. the export was the type of the global which is unconditionally defined.
  3. this module does not seem a suitable candidate for a UMD declaration.

* Use header version of 0.0; explain Stripe versioning in comments

* Restore global

* Added tests
2017-01-05 12:05:44 -08:00

270 lines
6.5 KiB
TypeScript

// Test file for Google Maps JavaScript API Definition file
var map = new google.maps.Map(document.querySelector("☺"));
/***** Data *****/
new google.maps.Data();
new google.maps.Data({ map: map });
var latLng = new google.maps.LatLng(52.201203, -1.724370),
feature = new google.maps.Data.Feature(),
geometry = new google.maps.Data.Geometry();
var data = map.data;
data.add(feature);
data.add({
geometry: latLng,
id: "Test feature",
properties: {}
});
var isIn: boolean = map.data.contains(feature);
data.forEach((feature: google.maps.Data.Feature) => {
console.log(feature.getId());
});
var map: google.maps.Map = data.getMap();
data.setMap(map);
var style = data.getStyle();
data.setStyle(style);
data.setStyle({
clickable: true,
cursor: "pointer",
fillColor: "#79B55B",
fillOpacity: 1,
icon: {},
shape: { coords: [1, 2, 3], type: "circle" },
strokeColor: "#79B55B",
strokeOpacity: 1,
strokeWeight: 1,
title: "string",
visible: true,
zIndex: 1
});
data.overrideStyle(feature, { visible: true });
data.revertStyle(feature);
data.addGeoJson({});
data.addGeoJson({}, { idPropertyName: "Test feature" });
data.loadGeoJson("http://magicGeoJsonSource.com");
data.loadGeoJson(
"http://magicGeoJsonSource.com",
{ idPropertyName: "test" });
data.loadGeoJson(
"http://magicGeoJsonSource.com",
{ idPropertyName: "test" },
(features) => {
for (var i = 0, len = features.length; i < len; i++) {
console.log(features[i].getId());
}
});
data.toGeoJson((feature) => { });
var dataMouseEvent: google.maps.Data.MouseEvent = {
feature: feature,
latLng: latLng,
stop: (): void => {}
};
var addFeatureEvent : google.maps.Data.AddFeatureEvent = {
feature: feature
};
var removeFeatureEvent: google.maps.Data.RemoveFeatureEvent = {
feature: feature
};
var setGeometryEvent: google.maps.Data.SetGeometryEvent = {
feature: feature,
newGeometry: geometry,
oldGeometry: geometry,
};
var setPropertyEvent: google.maps.Data.SetPropertyEvent = {
feature: feature,
name: "test",
newValue: {},
oldValue: {}
};
var removePropertyEvent: google.maps.Data.RemovePropertyEvent = {
feature: feature,
name: "test",
oldValue: {}
};
/***** Overlays *****/
var icon: google.maps.Icon = {
anchor: new google.maps.Point(16, 16),
origin: new google.maps.Point(0, 0),
scaledSize: new google.maps.Size(32, 32),
size: new google.maps.Size(32, 32),
url: "dummy"
};
/***** MapTypeStyle *****/
var mapTypeStyle: google.maps.MapTypeStyle ={
featureType: 'all',
};
var mapTypeStyle: google.maps.MapTypeStyle ={
featureType: 'administrative.country',
elementType: 'all',
stylers: [],
};
var mapTypeStyle: google.maps.MapTypeStyle ={
featureType: 'landscape.natural',
elementType: 'geometry',
stylers: [],
};
var mapTypeStyle: google.maps.MapTypeStyle ={
featureType: 'poi.school',
elementType: 'labels',
stylers: [],
};
// https://developers.google.com/maps/documentation/javascript/markers
function initMap1() {
var myLatLng = {lat: -25.363, lng: 131.044};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: myLatLng
});
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Hello World!'
});
}
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var mapOptions = {
zoom: 4,
center: myLatlng
}
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
title:"Hello World!"
});
// To add the marker to the map, call setMap();
marker.setMap(map);
marker.setMap(null);
// The following example creates a marker in Stockholm, Sweden using a DROP
// animation. Clicking on the marker will toggle the animation between a BOUNCE
// animation and no animation.
var marker: google.maps.Marker;
function initMap2() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 13,
center: {lat: 59.325, lng: 18.070}
});
marker = new google.maps.Marker({
map: map,
draggable: true,
animation: google.maps.Animation.DROP,
position: {lat: 59.327, lng: 18.067}
});
marker.addListener('click', toggleBounce);
}
function toggleBounce() {
if (marker.getAnimation() !== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
// In the following example, markers appear when the user clicks on the map.
// Each marker is labeled with a single alphabetical character.
var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var labelIndex = 0;
function initialize() {
var bangalore = { lat: 12.97, lng: 77.59 };
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: bangalore
});
// This event listener calls addMarker() when the map is clicked.
google.maps.event.addListener(map, 'click', function(event: any) {
addMarker(event.latLng, map);
});
// Add a marker at the center of the map.
addMarker(bangalore, map);
}
// Adds a marker to the map.
function addMarker(location: google.maps.LatLngLiteral, map: google.maps.Map) {
// Add the marker at the clicked location, and add the next-available label
// from the array of alphabetical characters.
var marker = new google.maps.Marker({
position: location,
label: labels[labelIndex++ % labels.length],
map: map
});
}
google.maps.event.addDomListener(window, 'load', initialize);
/***** OverlayView *****/
// https://developers.google.com/maps/documentation/javascript/customoverlays
var div = document.createElement('div');
var overlay = new google.maps.OverlayView();
var panes = overlay.getPanes();
panes.floatPane.appendChild(div);
panes.floatShadow.appendChild(div);
panes.mapPane.appendChild(div);
panes.markerLayer.appendChild(div);
panes.overlayImage.appendChild(div);
panes.overlayLayer.appendChild(div);
panes.overlayMouseTarget.appendChild(div);
panes.overlayShadow.appendChild(div);
/***** Rectangles *****/
// https://developers.google.com/maps/documentation/javascript/examples/rectangle-simple
var rectangle = new google.maps.Rectangle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35,
map: map,
bounds: {
north: 33.685,
south: 33.671,
east: -116.234,
west: -116.251
}
});