question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use google maps provided @Types file and make agm more extensible

See original GitHub issue

Issue description

Make AGM extensible and Use @Types/googlemaps so that features can be added easily

Steps to reproduce and a minimal demo of the problem

In its current form AGM uses custom mapTypes sometimes these Types slightly veer slightly from the googlemaps types and may be the source of some known bugs. I propose we use the @types/googlemaps dependency instead of custom types. This makes AGM easily extensible in most cases. I have made a pull request #1461 that is refactored to use googlemaps and also identified a number of variations from the @types library

What steps should we try in your demo?

you can build https://github.com/wdunn001/angular-google-maps and use it to try it I currently don’t have all the tests passing but it runs just fine I use it in my current project.

alternatively you can npm install --save @agme/core which I set up for my use

Current behavior agm uses custom mapTypes

Expected/desired behavior use the typings provided by google

angular2 & angular-google-maps version @latest

Other information

in addition, this pr identified numerous logic issues such as recasting of already typed values and redundant splice logic. some changes were required to make this compatible with googlemaps such as using a map(f => l.add(f)) to populate the features with the built in google maps funtion.

I found enum’s to be particularly problematic I implemented a switch case that could probrably be switched to a map.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
ideodoracommented, Sep 17, 2018

+1 I want MVCObject…specially #set #get agm types only defines addlistener…

0reactions
bleuscythercommented, May 27, 2019

i followed this approach : https://stackoverflow.com/a/55451667/1427338

/* /src/google-maps.d.ts */
import '@types/googlemaps';

declare global {
  interface Window {
    google: typeof google;
  }
}
/* /tsconfig.json  */
{
  ...
  "compilerOptions": {
    ...
    "typeRoots": [
      "node_modules/@types",
      "src/google-maps.d.ts"
    ],
   ...
  }
}

export classMyComponent implements OnInit {

    lat: number ;
    lng: number ;
    drawingManager: google.maps.drawing.DrawingManager;

   // wait for map to be ready or API to load
    onMapReady() {
        this.drawingManager = new google.maps.drawing.DrawingManager({
            // ...
        })
    }
}

NB: Don’t forget to restart the active ng serve session Also if you are using extra libraries like DrawingManager:

AgmCoreModule.forRoot({
      apiKey: 'YOUR_API_CODE',
      libraries: ['drawing']
    }),
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use google maps provided @Types file and make agm more ...
Issue description Make AGM extensible and Use @Types/googlemaps so that features can be added easily Steps to reproduce and a minimal demo ...
Read more >
Use google maps provided @Types file and make agm more ...
Issue description. Make AGM extensible and Use @Types/googlemaps so that features can be added easily. Steps to reproduce and a minimal demo of...
Read more >
Getting started with Angular Google Maps (AGM)
Open src/app/app.module.ts and import the AgmCoreModule . You neeed to provide a Google Maps API key to be able to see a Map....
Read more >
Integrating Google maps in Angular | by Hassam Ali - Medium
Google maps are one of the most widely used maps on the internet. They are very detailed and extensible. In this article I...
Read more >
Trouble getting Angular Google Map AGM to work with ...
I ran the following command and I was able to see it work as expected. npm i @types/googlemaps@3.39.13 --save-dev.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found