Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): fix non working tile update #5041

Conversation

mateki0
Copy link
Collaborator

@mateki0 mateki0 commented Apr 25, 2024

Does any other open PR do the same thing?

No

What issue is this PR fixing?

#5012

How did you test this PR?

It affects only Android Google Maps.
I have tested it on Android Simulator(Pixel 2a), for some reason map is not rendering on my real device but there shouldn't be difference between simulator and device.

To test it easily you can copy/paste this code to any of existing example screens. I was using StaticMap but it doesn't matter.

import React, {useState} from 'react';
import MapView, {Marker, UrlTile} from 'react-native-maps';

import {View, Text, TouchableOpacity} from 'react-native';

const coord = {
  lat: 37.78825,
  lon: -122.4324,
};

const StaticMap = () => {
  const [tileUrl, setTileUrl] = useState(
    'https://cartodb-basemaps-c.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
  );

  const swapTile = () => {
    if (tileUrl.includes('dark_all')) {
      setTileUrl(
        'https://cartodb-basemaps-c.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
      );
    } else {
      setTileUrl(
        'https://cartodb-basemaps-c.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png',
      );
    }
  };

  return (
    // eslint-disable-next-line react-native/no-inline-styles
    <View style={{flex: 1, width: '100%', height: '100%'}}>
      <MapView
        pitchEnabled={false}
        rotateEnabled={false}
        // eslint-disable-next-line react-native/no-inline-styles
        style={{flex: 1, width: '100%', height: '100%'}}
        initialRegion={{
          latitude: coord.lat,
          longitude: coord.lon,
          longitudeDelta: 20,
          latitudeDelta: 20,
        }}>
        <Marker coordinate={{latitude: coord.lat, longitude: coord.lon}} />
        <UrlTile opacity={0.6} urlTemplate={tileUrl} />
      </MapView>

      <View
        // eslint-disable-next-line react-native/no-inline-styles
        style={{
          flex: 1,
          flexDirection: 'row',
          alignItems: 'center',
          paddingHorizontal: 20,
        }}>
        <TouchableOpacity onPress={swapTile}>
          <Text>Swap tile</Text>
        </TouchableOpacity>
      </View>
    </View>
  );
};

export default StaticMap;

This solution is basing on similar code in MapTileProvider in setTileSize.

@salah-ghanim
Copy link
Collaborator

@mateki0 please rebase or "allow maintainers to update branch" in the future to enable me to trigger a rebase so that this can be merged

@mateki0
Copy link
Collaborator Author

mateki0 commented May 5, 2024

@mateki0 please rebase or "allow maintainers to update branch" in the future to enable me to trigger a rebase so that this can be merged

@salah-ghanim I rebased it. I don't have this option, it should be on the right side under participants section, right?

@salah-ghanim salah-ghanim merged commit 29107d5 into react-native-maps:master May 5, 2024
4 checks passed
react-native-maps-bot pushed a commit that referenced this pull request May 5, 2024
## [1.15.1](v1.15.0...v1.15.1) (2024-05-05)

### Bug Fixes

* **android:** fix non working tile update ([#5041](#5041)) ([29107d5](29107d5))
@react-native-maps-bot
Copy link
Collaborator

🎉 This PR is included in version 1.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mateki0
Copy link
Collaborator Author

mateki0 commented May 6, 2024

Screenshot 2024-05-06 at 08 39 09

Yea I saw it but I don't have this section at all :/

DavidLee0501 added a commit to DavidLee0501/React-Native-Map that referenced this pull request Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants