question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor www/googlemaps-cdv-plugin.js

See original GitHub issue

I’m submitting a … (check one with “x”)

  • question
  • any problem or bug report
  • feature request
  • contribution

If you choose ‘problem or bug report’, please select OS: (check one with “x”)

  • Android
  • iOS

I’d like to refactor www/googlemaps-cdv-plugin.js as it contains a lot of complicated logic. That logic is really hard to understand, also I see there are some code duplication which adds in size in resulting app bundle (js evaluation take time especially at 1st boot).

Why?

  • this will improve codebase, thus it will be easier to make contributions
  • this will decrease amount of js code, so app will load faster
  • this will allow to remove redundant/dead code
  • this will allow to write unit tests for almost every file in the plugin
  • this will allow to refactor some recursive calls with loops (loops are faster than recursion in JS)

What I eventually plan to do is to split that logic between 3 objects:

  • MapFactory - responsible for Map creation, will be used instead of massive logic in getMap function
  • MapsApi - easy interface to make native API calls to GoogleMaps related plugins (this will encapsulate Command queue mechanism). This interface I plan to build based on promises
  • DomObserver - object which will walk over DOM elements and collect their rects, zIndex, etc and watch when they changed

I started to do this in my fork, so you are welcome to check the first results here. This is the initial refactoring.

Currently what I ended up with is in https://github.com/stalniy/cordova-plugin-googlemaps/tree/refactor/map . This is still not final version but very close to that. Currently I’m testing every usecase from v2.0 demo repo.

Let me know whether you interested in merging this into core project!

Thanks for awesome plugin!

P.S.: also I’d like to remove existing polyfills from the project and just add a note that this project requires that polyfills on older webviews. This will allow people to choose whatever polyfill library they like 😃 Also this will decrease the resulting js size of the plugin. Obviously this may be discussed in a separate ticket

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:33 (30 by maintainers)

github_iconTop GitHub Comments

2reactions
stalniycommented, Feb 24, 2018

Hi @wf9a5m75

I think that you did is awesome! Despite the fact that there is a room for improvements, I wouldn’t be able to suggest them if you didn’t create this plugin.

Also I know that I don’t understand the whole picture. That’s why I stopped my refactoring and decided to ask for your help (guidance) in this job.

@cvaliere, I don’t think that blaming somebody will help you to create a better software. And I’d recommend to work In cooperation with others to create awesome things. Isn’t this how Open Source was created or how vendors of browsers decided to standardize JS and web?

Let’s be polite guys as we are from different cultures and may do mistakes in phrases, words or meanings when we talk using not our native language.


@wf9a5m75 I plan to spend some time today looking into your comments and fixing them. Thanks for the guidance, your work and patience!

1reaction
wf9a5m75commented, Mar 24, 2018

Since the refactoring is done at once, I close this thread. But please send a new pul request with improvement. I really appreciate for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Maps JavaScript API V3 Reference
Google Maps JavaScript API V3 Reference ... This is an index of all the classes, methods, and interfaces in the Maps JavaScript API...
Read more >
A Year of Google & Apple Maps - Justin O'Beirne
This essay no longer reflects the current state of Google & Apple Maps ... Google has repeatedly refactored the styling of its map...
Read more >
@googlemaps/markerclusterer - npm
Creates and manages per-zoom-level clusters for large amounts of markers.. Latest version: 2.0.14, last published: a month ago.
Read more >
Google Maps
Find local businesses, view maps and get driving directions in Google Maps.
Read more >
Google Maps
Menu Back. Search Google Maps. Search. Directions. Collapse side panel. When you have eliminated the JavaScript, whatever remains must be an empty page....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found