Add the user-specified location in the input field by clicking the button to stop the geocompletion

My requirement is to insert a place name in the text box and show what is on the map, so I used geocomplete js, which works well.

Now my user should be able to place user-defined places, such as "my home", for this I need to remove the geocomponent by clicking the "x" button on top of the map.

How to implement this?

Thanks in advance

+8
jquery android google-maps cordova geolocation
source share
1 answer

I would not configure the package! When the new version comes out, you will have to make the same changes as before.

Since you have not provided any code, I can give you an idea of โ€‹โ€‹what I did with overriding the JQuery validation method.

You just need to find the listener (something like $('#listenToThis').on('click', function(){ doThings(); } ) in the geocomplete.js file, and then override it in the file that is included after geocomponent.

If you use packages, simply include your file after the response for the response to the geocomponent is determined.

So, after you find them, you can do something similar to the following:

 $.validator.methods.number = function (value, element) { value = floatValue(value); return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:[\s\.,]\d{3})+)(?:[\.,]\d+)?$/.test(value); } 

The above function allowed me to check client-side numbers that were formatted as currency in jQuery ($).

This overrides the JQuery.validator.methods.number function (a cheating method to override the function without changing the package code), so if you can define the geocomplete.addSomethingToMap or geocomplete.reactToClick function, you must override it and it will work this way.

Warning: you need to re-enable changes if you want to reuse this feature. You will have to override, override, override again. This may not be the best way if they are going to add hundreds of different new places to one screen, but for a small device, such as a dozen, this should be a good solution.

+1
source share

All Articles