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.

Does not work with any of the map APIs (re-rendering incompatibility)

See original GitHub issue

Expected behavior

With the library like leafletjs or google maps API, choo should render a geo map and then update (re-render) it without any problem.

Actual behavior

Upon emitting render with updated coordinates (latitude and longitude), every map implementation dies and then displays blank container or , alternatively, empty, grey map. Tested with:

  1. Leaflet
  2. Google Maps
  3. Mapbox GL

It results in the same outcome.

Steps to reproduce behavior

Example code (map component):

import html from 'choo/html';

export default ({latitude = 51.505, longitude = -0.09, zoom = 18, markers = []},
    emit) => {
    const geoMap = html`<div id="map" style="height: 380px"></div>`;
    if (typeof L !== 'undefined') {
            const map = L.map(geoMap).setView([latitude, longitude], zoom);
            L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
                attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
                maxZoom: zoom,
                id: 'mapbox.streets',
                accessToken: 'apiTokenHere'
            }).addTo(map);    
    }
    return geoMap;
};

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
yoshuawuytscommented, May 31, 2017

Check out the example in https://github.com/yoshuawuyts/nanocomponent, you need to make sure that the DOM element is not recreated on each render, nanocomponent (and https://github.com/yoshuawuyts/microcomponent) help with this (:

On Wed, May 31, 2017 at 8:21 PM Maciej Sitko notifications@github.com wrote:

Yup, the rerender of anything apparently kills all maps.

There has to be a way not to do this as this makes geocoding impossible.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yoshuawuyts/choo/issues/507#issuecomment-305273961, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWlej4RbDafrKCvQOPP3fCwb23FiU9Rks5r_a-xgaJpZM4Nr5sx .

0reactions
graforlockcommented, Jun 2, 2017

You are right, its even on the forefront of github 😃 My bad

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-google-maps use without re-render - Stack Overflow
I Have 1 task and 1 problem. I use react-google-maps . My task is: add markers by the event. My problem - after...
Read more >
google-map-react now load google maps api all the time even ...
UPDATE: It seems 2.1.3 seems to work. Note that this issue happens because I need to dynamically load google maps for other components...
Read more >
Error Messages | Maps JavaScript API - Google Developers
If you receive only warnings without any errors, the API will work correctly on that page. However, we recommend that you fix these...
Read more >
react-native-maps - npm
Issue: Since android needs to render its marker views as a bitmap, the animations APIs may not be compatible with the Marker views....
Read more >
Backbone.js
Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable ...
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