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

Problem with addMarker() #1730

Closed
marouan-fr opened this issue Sep 12, 2017 · 12 comments
Closed

Problem with addMarker() #1730

marouan-fr opened this issue Sep 12, 2017 · 12 comments

Comments

@marouan-fr
Copy link

marouan-fr commented Sep 12, 2017

I'm submitting a ... (check one with "x")
[ ] question
[x ] any problem or bug report
[ ] feature request

The plugin version: (check one with "x")
[ x] 2.0-beta3 (github)
[ ] 2.0 (npm)

If you choose 'problem or bug report', please select OS: (check one with "x")
[x ] Android
[ ] iOS

cordova information: (run $> cordova plugin list)

cordova-plugin-googlemaps 2.0.6-beta-20170906-2336 "cordova-plugin-googlemaps"

If you use @ionic-native/google-maps, please show me the package.json
"@ionic-native/google-maps": "^4.2.1"

placeMarker(LatLng) {
    if (this.marker) {
      this.marker.setPosition(LatLng);
    } else {
      this.map.addMarker({
        position: LatLng,
        draggable: true,
        icon: 'green',
        animation: 'DROP'
      }).then(marker => this.marker = marker);
    }
  }
      this.map.on(GoogleMapsEvent.MAP_CLICK)
          .subscribe((LatLng) => {
            this.placeMarker(LatLng);
          });

nothing happens, with no error on the console.

same problem, when i called an addMarker after this.map.animateCamera({ ... }).then( () => this.map.addMarker( .... ) )}

all of this is under this.map.one(GoogleMapsEvent.MAP_READY) , i dont know through what's causing the problem

@marouan-fr
Copy link
Author

i even tried
m = plugin.google.maps.Map.getMap(map)
m.addMarker(m.getCameraPosition().target)
on the console directly (via chrome inspect), and its undefined, nothing happens

@marouan-fr marouan-fr changed the title Problem w< Problem with addMarker() Sep 12, 2017
@wf9a5m75
Copy link
Member

Please share your project filea on github.

@marouan-fr
Copy link
Author

I updated ionic-native to 4.2.1 (core and google-maps) and i did more testing :

this.map.one(GoogleMapsEvent.MAP_READY)
      .then(() => {
           
      this.map.on(GoogleMapsEvent.MAP_CLICK)
          .subscribe((LatLng) => {
            this.placeTarget(LatLng); // dont work
          });

      this.map.getMyLocation()
          .then(loc => {
            // get location and center the camera
            this.map.animateCamera({
              target: {
                lat: loc.latLng.lat,
                lng: loc.latLng.lng
              },
              zoom: 18,
              tilt: 50,
              duration: 1500,
            }).then(() => {
              this.map.panBy(0, 120);
              this.placeOther(); // dont work either
            });
          });

      this.placeMarker(); // this one workes
     })

those 3 functions have addMarkers, the only one that works is the one directly under MAP_READY, not after (i don't know how this is possible)

@wf9a5m75
Copy link
Member

Please share your project files on github, not part of code.
If you don't want to share your project files, please create a demo project.

@marouan-fr
Copy link
Author

@marouan-fr
Copy link
Author

I downgraded the plugin to old commit to make it works again, at least temporary till it's fixed.
There is many other problems in the last release, marker.setVisible() .. and more.

@wf9a5m75
Copy link
Member

Thank you for preparng.
Actually the @ionic-native/google-maps wrapper plugin has lots of bugs (and it is not my plugin).
I already sent a PR to fix of the on() method.

danielsogl/awesome-cordova-plugins#1956

I will check your repo later , but it seems your issue is the bug of the wrapper plugin.

@marouan-fr
Copy link
Author

im now working with an old commit of your plugin https://github.com/mapsplugin/cordova-plugin-googlemaps#5692f3d1b78d7693b0fd01b6ad8f87017c550e45
(my problem started when i upgraded the plugin)
using the same ionic-native package, every think works fine.

I even tested with chrome console, plugin.google.maps.Map works on old versions, but not the new release. (thats not ionic wrapper )

@wf9a5m75
Copy link
Member

ok, I will check your repo later.

@wf9a5m75
Copy link
Member

Um, it seems the code and the values are correct, but the native Maps API does not plot markers for some reason. I'm inspecting.

@wf9a5m75
Copy link
Member

Thank you for sharing the project. That saved a lot of my work time.
I finally figured out the problem and fix it.
Please reinstall the plugin from the multiple_maps branch

cordova pluign add https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps ...

issue_1730_after

@wf9a5m75 wf9a5m75 added the fixed label Sep 13, 2017
@marouan-fr
Copy link
Author

I'm glad to help, this will help me back in my project as well.
When i got the time, i will try to work more on the ionic demo :)

wf9a5m75 added a commit that referenced this issue Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants