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

[Bug]: projection mercator not working #3254

Closed
Ladvace opened this issue Dec 8, 2023 · 8 comments
Closed

[Bug]: projection mercator not working #3254

Ladvace opened this issue Dec 8, 2023 · 8 comments
Labels
bug 🪲 Something isn't working

Comments

@Ladvace
Copy link

Ladvace commented Dec 8, 2023

Mapbox Implementation

Mapbox

Mapbox Version

default

Platform

iOS

@rnmapbox/maps version

^10.0.15

Standalone component to reproduce

import React, { useEffect, useState, useRef } from "react";
import { Alert, Image, StyleSheet, View } from "react-native";
import Mapbox from "@rnmapbox/maps";
import * as Location from "expo-location";
import { Button } from "react-native";

Mapbox.setAccessToken(
  "MY_TOKEN"
);

const App = () => {
  const [location, setLocation] = useState();


  useEffect(() => {
    (async () => {
      let { status } = await Location.requestForegroundPermissionsAsync();
      if (status !== "granted") {
        return;
      }

      let location = await Location.getCurrentPositionAsync({});

      setLocation(location);
    })();
  }, []);

  return (
    <View style={styles.page}>
      <View style={styles.container}>
        <Mapbox.MapView
          style={styles.map}
          followsUserLocation={true}
          region={location?.coords || []}
          projection="mercator"
          compassEnabled
          onLongPress={(f) => {
            console.log("Coordinates", f.geometry.coordinates);
          }}
        >
        </Mapbox.MapView>
      </View>
    </View>
  );
};

export default App;

const styles = StyleSheet.create({
  page: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
  },
  container: {
    height: "100%",
    width: "100%",
  },
  map: {
    flex: 1,
  },
  annotationContainer: {
    alignItems: "center",
    backgroundColor: "white",
    borderColor: "rgba(0, 0, 0, 0.45)",
    borderRadius: 50 / 2,
    borderWidth: StyleSheet.hairlineWidth,
    height: 50,
    justifyContent: "center",
    overflow: "hidden",
    width: 50,
  },
});

Observed behavior and steps to reproduce

when I set the projection to mercator on the Mapbox.MapView I still see the globe and not the "flat" Mercator map

Expected behavior

No response

Notes / preliminary analysis

No response

Additional links and references

No response

@Ladvace Ladvace added the bug 🪲 Something isn't working label Dec 8, 2023
@mfazekas
Copy link
Contributor

mfazekas commented Dec 9, 2023

import React, { useEffect, useState, useRef } from 'react';
import { Alert, Image, StyleSheet, View } from 'react-native';
import Mapbox from '@rnmapbox/maps';
import { Button } from 'react-native';

const App = () => {
  const [location, setLocation] = useState();

  return (
    <View style={styles.page}>
      <View style={styles.container}>
        <Mapbox.MapView
          style={styles.map}
          followsUserLocation={true}
          region={location?.coords || []}
          projection="mercator"
          compassEnabled
          onLongPress={(f) => {
            console.log('Coordinates', f.geometry.coordinates);
          }}
        />
      </View>
    </View>
  );
};

export default App;

const styles = StyleSheet.create({
  page: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  container: {
    height: '100%',
    width: '100%',
  },
  map: {
    flex: 1,
  },
  annotationContainer: {
    alignItems: 'center',
    backgroundColor: 'white',
    borderColor: 'rgba(0, 0, 0, 0.45)',
    borderRadius: 50 / 2,
    borderWidth: StyleSheet.hairlineWidth,
    height: 50,
    justifyContent: 'center',
    overflow: 'hidden',
    width: 50,
  },
});
image

If I run this code I don't see a globe.

@mfazekas mfazekas closed this as completed Dec 9, 2023
@Ladvace
Copy link
Author

Ladvace commented Dec 9, 2023

I have to check why in my case it get ignored then

@Ladvace
Copy link
Author

Ladvace commented Dec 9, 2023

basically It works fine on android but not on IOS

@mfazekas
Copy link
Contributor

mfazekas commented Dec 9, 2023

I've tested on iOS simulator. Are you trying the exact same component as described on #3254 (comment), can you take a screenshot?

@Ladvace
Copy link
Author

Ladvace commented Dec 9, 2023

the only different is actually a custom styleURL I've applied and it actually seems working without it

@RemiHin
Copy link

RemiHin commented Jan 12, 2024

Im running in to this issue right now. Happens when i use the mapbox://styles/mapbox/dark-v11, mapbox://styles/mapbox/satellite-streets-v12, mapbox://styles/mapbox/light-v11, mapbox://styles/mapbox/outdoors-v12 or mapbox://styles/mapbox/streets-v12 styleUrl,

but not when using the others listed here: https://docs.mapbox.com/api/maps/styles/#classic-mapbox-styles

@Ladvace did ever solve it?

@Crysp
Copy link

Crysp commented Mar 25, 2024

@RemiHin you can solve it with custom styles. Create your own style in "Mapbox Studio" from default mapbox://styles/mapbox/streets-v12 and set projection to "mercator" as default.

@Ladvace
Copy link
Author

Ladvace commented Nov 4, 2024

@RemiHin sorry for late reply, I got the same problem, I managed to "fix" just not using the styling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants