impress-org / google-maps-builder

One Google Maps plugin to rule them all. Google Maps Builder is intuitive, sleek, powerful and easy to use. Forget the rest, use the best.
https://wordpress.org/plugins/google-maps-builder/
32 stars 9 forks source link

Improve Performance (loading hidden maps / loading lots of markers) #251

Closed MALIK-0 closed 7 years ago

MALIK-0 commented 7 years ago

I'm using a hidden map which loads a lot of mashup markers. The current performance is very poor, since the way the plugin is written a hidden map gets loaded twice.

Loading hidden maps: Every map is loaded at document ready by default through the method "gmb.init" (also hidden maps). To show hidden maps another method "gmb.load_hidden_map" is used. Internally both methods call "gmb.initialize_map" which just loads the map.

It would be better to load the map by default and instead of loading hidden maps again just resize them. There is also a comment in the "gmb.load_hidden_map" method which mentions that.

Caching mashup markers: Is there an existing way of caching the mashup markers, so the map loads faster, since it already has the data and no additional database request is needed?

Maybe a loading animation would also improve user experience since, the user then knows that something is loading. Otherwise the user just sees a blank map, until markers are loaded.

See the map in action, scroll down to the "reference list section" and activate the map by clicking the small globe icon (uses gmb.load_hidden_map): http://braukon.de/en/references/

kevinwhoffman commented 7 years ago

@TobiasMalikowski Great suggestions. We'll be addressing both points in the upcoming 2.1.2 release:

  1. When a hidden map is loaded, we are now checking whether that map has already been initialized. If it does not yet exist, it is initialized. If it does exist, we only trigger a resize and re-centering of the map to ensure it displays correctly upon reveal. This means markers aren't being queried more often than they need to be after the map has been initialized.
  2. Mash-up markers will load from transients if available to reduce expensive queries. This should be especially helpful for maps with many markers and multiple mash-up layers. If a mash-up post's location is updated, the transient associated with that post type will be deleted to ensure the map immediately reflects those changes.

Thanks again for your feedback and contributions!