Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(polygon, polyline): add getPath and getPaths #991

Closed
wants to merge 2 commits into from

Conversation

willshowell
Copy link
Contributor

Adds the MVCArray type and wrappers for the getPath() and getPaths() Google Maps API methods.

This should partially address requirements in #823

Adds the MVCArray type and wrappers for the
`getPath()` and `getPaths()` Google Maps API methods.
@abalad
Copy link

abalad commented Apr 18, 2017

@willshowell lol Thanks

@willshowell
Copy link
Contributor Author

@SebastianM @lazarljubenovic any chance of getting this reviewed? As far as I can tell, editable polygons are useless without a way to later retrieve the path.

@vsaravind007
Copy link

Hi @willshowell Any chance of an example on Plunker? Not been successful so far!

@willshowell
Copy link
Contributor Author

@vsaravind007

import { Component, ViewChild } from '@angular/core';
import { AgmPolygon } from '@agm/core';

@Component({
  selector: 'app-root',
  styleUrls: ['./app.component.css'],
  template: `
    <agm-map
      [latitude]="lat"
      [longitude]="lon"
      [zoom]="zoom">
      <agm-polygon
        [paths]="path"
        [polyDraggable]="true"
        [editable]="true">
      </agm-polygon>
    </agm-map>
    <button (click)="getPath()">GET PATH</button>
  `
})
export class AppComponent {
  @ViewChild(AgmPolygon) polygon: any;

  // google maps zoom level
  zoom: number = 8;

  // initial center position for the map
  lat: number = 51.673858;
  lng: number = 7.815982;

  path = [
    { lat: 51.791629704426924, lng: -0.8624267578125 },
    { lat: 51.974729774949644, lng: 0.6317138671875 },
    { lat: 51.303145259199056, lng: 0.6646728515625 },
    { lat: 51.416338106400396, lng: -0.4779052734375 }
  ];

  getPath() {
    this.polygon.getPaths().then((x: any[]) => {
      x.forEach(y => {
        console.log('-');
        y.forEach(z => console.log(z.lat(), z.lng()));
      });
    });
  }

}

Note that you'll probably also need the changes from #990

Hope that helps!

@gaalvarez
Copy link

@willshowell how can I use your changes in this pull from my angular project? thanks

@Epenance
Copy link

Epenance commented Aug 1, 2017

It would be super neat to have this merged in, or a similar feature made at least. Its currently impossible to get the new paths of the polygon after it has been edited which is a shame.

@ghost
Copy link

ghost commented Sep 26, 2017

@willshowell any chance you can update this for conflicts, and then we can all yell at @SebastianM to merge this? I am stuck without this.

@Jooeeyy
Copy link

Jooeeyy commented Jun 17, 2018

What's up with this? Would be happy if this could be merged.

@daanvanrobays
Copy link

I would also be happy to see this getting merged. I've spend too much time already trying to find another way around.

@ghal
Copy link

ghal commented Jun 28, 2018

I would be happy if this could be merged.

@stale
Copy link

stale bot commented Nov 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2018
@youuri
Copy link

youuri commented Nov 20, 2018

What the point with this issues?

@stale stale bot removed the stale label Nov 20, 2018
@stale
Copy link

stale bot commented Feb 18, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 18, 2019
@ghost
Copy link

ghost commented Feb 18, 2019

@willshowell can you please fix conflicts? Also, while this is nice, what we really need is a path event.

@stale stale bot removed the stale label Feb 18, 2019
@willshowell willshowell closed this Apr 3, 2019
@lakhvir-singh
Copy link

lakhvir-singh commented Nov 29, 2019

#991 (comment)

How can I get the coordinates of another map on same component?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.