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

Possibility to pass custom variables to a marker #54

Closed
em-ka opened this issue May 13, 2014 · 5 comments
Closed

Possibility to pass custom variables to a marker #54

em-ka opened this issue May 13, 2014 · 5 comments

Comments

@em-ka
Copy link

em-ka commented May 13, 2014

Hi,
I would appreciate a possibility to set custom variables to a marker. e.g. when you want to show additional information after user clicks on an info window (you need to pass some kind of an ID, to be able to show them).

@jskidd3
Copy link

jskidd3 commented May 13, 2014

Hi @em-ka,

You should be able to do this already.

I have written a code example below:

var myMarker = null;

this.map.addMarker({
    icon: icon,
    position: new plugin.google.maps.LatLng(myLatitude, myLongitude),
}, function(marker) {
    // Set your custom properties/methods here
    marker.code = code;
    marker.name = name;
    marker.direction = direction;
    marker.alert = alertMessage;

    myMarker = marker;
});

@em-ka
Copy link
Author

em-ka commented May 13, 2014

Hi @jskidd3,
thank you very much! I've solved my issue by modifying googlemaps-cdv-plugin.js (I have added method marker.getParams()), so I can use code like this:

this.map.addMarker({
        icon: icon,
        position: new plugin.google.maps.LatLng(myLatitude, myLongitude),
        params: {
            alert: 'test'
        }
    }, function(marker) {
        alert(marker.getParams().alert);
    }
);

But yours example is much less complicated. Thank you.

@jskidd3
Copy link

jskidd3 commented May 13, 2014

No problem! Glad I could help :-)

@wf9a5m75
Copy link
Member

Thank you, @jskidd3

@Jerome2606
Copy link
Contributor

@em-ka Could you submit a pull request for this because I need it too but I don't know how to reproduce your change ?

Thanks

Jerome2606 added a commit to Jerome2606/phonegap-googlemaps-plugin that referenced this issue Jul 30, 2015
mapsplugin#54
Add a params object to marker to add specific parameters (like Id, url, etc.) that can be use in infoClick or other events from marker.getParams()
hirbod pushed a commit that referenced this issue Aug 31, 2015
Pass custom variables to a marker #54
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

No branches or pull requests

4 participants