Skip to content

Commit

Permalink
fix(map): markers not displaying correctly (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloman authored Nov 7, 2023
1 parent 4b8ea97 commit 5a17b05
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-shirts-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@balloman/expo-google-maps": patch
---

Fixed markers not displaying correctly if the size wasn't set
10 changes: 5 additions & 5 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@balloman/expo-google-maps";
import * as Location from "expo-location";
import React, { useEffect } from "react";
import { Button, StyleSheet, View } from "react-native";
import { Button, StyleSheet, Text, View } from "react-native";

import styleJson from "./style.json";

Expand Down Expand Up @@ -96,11 +96,11 @@ export default function App() {
<View
style={{
alignItems: "center",
backgroundColor: "red",
width: 100,
height: 100,
backgroundColor: "blue",
}}
/>
>
<Text>Hello World</Text>
</View>
</MarkerView>
</MapView>
<View style={{ position: "absolute", top: "50%", alignSelf: "center" }}>
Expand Down
2 changes: 2 additions & 0 deletions ios/Views/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class MapView: ExpoView, GMSMapViewDelegate {
markerView.setMap(withMap: mapView)
markers[key] = markerView
}
super.insertReactSubview(subview, at: atIndex)
}

override func removeReactSubview(_ subview: UIView!) {
Expand All @@ -49,6 +50,7 @@ class MapView: ExpoView, GMSMapViewDelegate {
markerView.gmsMarker.map = nil
markers.removeValue(forKey: key)
}
super.removeReactSubview(subview)
}

func animateCamera(to: GMSCameraPosition, animationOptions: AnimateOptions) {
Expand Down
9 changes: 8 additions & 1 deletion src/MarkerView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { requireNativeViewManager } from "expo-modules-core";
import * as React from "react";
import { View } from "react-native";

import { Coordinate } from "./ExpoGoogleMaps.types";

Expand Down Expand Up @@ -27,5 +28,11 @@ const NativeView: React.ComponentType<MarkerViewProps> =
requireNativeViewManager("ExpoGoogleMapsMarker");

export function MarkerView(props: MarkerViewProps) {
return <NativeView {...props} />;
return (
<NativeView {...props}>
{props.children && ( // Due to some weirdness with the native view, we need to wrap the children in an absolute view
<View style={{ position: "absolute" }}>{props.children}</View>
)}
</NativeView>
);
}

0 comments on commit 5a17b05

Please sign in to comment.