How can I make function?


I don’t know what that mean.

I just want to make markers, when map is clicked, so use eventhandler for ‘click’, but It makes typeError.

but when i put the same code into the drawing map, it works.

  placeMarker(latLng, map){

      let marker = new google.maps.Marker({
          position: latLng,
          map: map

with'click', function(event) {


this code from javascript, not plugin about cordova

can you give me a comment why that didn’t work??

thanks for reading

Change that to'click', event => {

this is replaced with the function itself when you use function() {}, so use the arrow functions

    () => {
        // No parameters

    result => {
        // 1 parameter

    (result, rows) => {
        // Multiple parameters

Oh… thanks for your reply.

It works perfectly.

can I ask you why unarrow function didn’t work?

I think arrow function is optional. Isn’t it? I can’t select? It is essential?

It depends where you use it. If you want to keep what’s within this, use arrow functions. And personally, I just think it’s neater :wink:

thanks mich!

have a good day!

I would strongly recommend using ionic-native when interacting with plugins. It will make your code more idiomatic, and would have saved you from this problem.

and if someone is interested how to set the context of a function in plain javascript:'click', function (event) {
  // this is the outer context this ;)

you said me to use google-map-plugin?

I have thought about that, but It tuned to cordova, and Ionic2 use typescript, so I think it might be hard to use.

and plugin version 1.x is stopped, version 2.x is going now but API is not stabilized.

perhaps, plugin has better performance?

better performance about google map? (about map loading or so)