Socket
Socket
Sign inDemoInstall

@dotdev/reactive-google-map

Package Overview
Dependencies
Maintainers
13
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotdev/reactive-google-map - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

3

dist/utility/geocoder.d.ts

@@ -5,7 +5,6 @@ /**

*/
import * as GoogleMaps from "@google/maps";
export declare class Geocoder {
options: Geocoder.Options;
client: GoogleMaps.GoogleMapsClient;
constructor(options: Geocoder.Options);
static InjectGoogleMapsWithGeocoder: (googleMapsApiVersion: string, googleMapsApiKey: string) => Promise<void>;
addressToLatLng: (address: string) => Promise<Geocoder.Position>;

@@ -12,0 +11,0 @@ latLngToAddress: (position: Geocoder.Position) => Promise<any>;

@@ -41,4 +41,4 @@ "use strict";

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var GoogleMaps = require("@google/maps");
var utility_1 = require("../utility");

@@ -50,9 +50,19 @@ var Geocoder = /** @class */ (function () {

this.addressToLatLng = function (address) { return __awaiter(_this, void 0, void 0, function () {
var response, result;
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.client.geocode({ address: address }).asPromise()];
case 0: return [4 /*yield*/, Geocoder.InjectGoogleMapsWithGeocoder(this.options.googleMapsApiVersion, this.options.googleMapsApiKey)];
case 1:
response = _a.sent();
result = response.json.results[0];
_a.sent();
return [4 /*yield*/, new Promise(function (resolve, reject) {
var geocoder = new google.maps.Geocoder();
var response = geocoder.geocode({ address: address }, function (results) {
if (!results || results.length === 0) {
return reject(new Error("Unable to find address."));
}
return resolve(results[0]);
});
})];
case 2:
result = _a.sent();
if (!result || !result.geometry || !result.geometry.location) {

@@ -68,20 +78,14 @@ throw new Error("Unable to Geolocate.");

switch (_a.label) {
case 0:
if (!(!window.hasOwnProperty("google") || !google.maps.Geocoder)) return [3 /*break*/, 2];
if (!this.options.googleMapsApiVersion || !this.options.googleMapsApiKey) {
throw new Error("Google Maps API has not been pre-loaded and no Version or API Key has been provided.");
}
return [4 /*yield*/, utility_1.InjectScript("https://maps.google.com/maps/api/js?v=" + this.options.googleMapsApiVersion + "&key=" + this.options.googleMapsApiKey + "&libraries=places")];
case 0: return [4 /*yield*/, Geocoder.InjectGoogleMapsWithGeocoder(this.options.googleMapsApiVersion, this.options.googleMapsApiKey)];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
var geocoder = new google.maps.Geocoder();
var response = geocoder.geocode({ location: position }, function (results) {
if (!results || results.length === 0) {
return reject(new Error("Unable to find address."));
}
return resolve(results[0]);
});
})];
return [2 /*return*/, new Promise(function (resolve, reject) {
var geocoder = new google.maps.Geocoder();
var response = geocoder.geocode({ location: position }, function (results) {
if (!results || results.length === 0) {
return reject(new Error("Unable to find address."));
}
return resolve(results[0]);
});
})];
}

@@ -101,7 +105,19 @@ });

};
this.client = GoogleMaps.createClient({
key: this.options.googleMapsApiKey,
Promise: Promise,
}
Geocoder.InjectGoogleMapsWithGeocoder = function (googleMapsApiVersion, googleMapsApiKey) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(!window.hasOwnProperty("google") || !google.maps.Geocoder)) return [3 /*break*/, 2];
if (!googleMapsApiVersion || !googleMapsApiKey) {
throw new Error("Google Maps API has not been pre-loaded and no Version or API Key has been provided.");
}
return [4 /*yield*/, utility_1.InjectScript("https://maps.google.com/maps/api/js?v=" + googleMapsApiVersion + "&key=" + googleMapsApiKey + "&libraries=places")];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2 /*return*/];
}
});
}
}); };
Geocoder.latLngToDirections = function (destination, origin) {

@@ -108,0 +124,0 @@ if (origin === void 0) { origin = "My+Location"; }

{
"name": "@dotdev/reactive-google-map",
"version": "1.0.0",
"version": "1.0.1",
"main": "dist/index.js",

@@ -15,3 +15,2 @@ "types": "dist/index.d.ts",

"devDependencies": {
"@types/google__maps": "^0.5.2",
"@types/react": "^16.8.6",

@@ -24,3 +23,2 @@ "@types/react-dom": "^16.8.2",

"dependencies": {
"@google/maps": "^0.5.5",
"@google/markerclustererplus": "^2.1.11",

@@ -27,0 +25,0 @@ "react": "^16.8.3",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc