Comments (6)
FYI: googlemaps/react-wrapper#642
from google-map-react.
I found a workaround until this issue get resolved;
with react 18 you can use createRoot
method from 'react-dom/client'
module so, in the onGoogleApiLoaded
callback it is possible to render your custom marker into the map dynamically;
import { createRoot } from 'react-dom/client';
...
const HQMarkerTemplate: React.FC = () => (
<>
<div>Test Marker</div>
</>
);
export const MapHandler = () => {
const handleApiLoaded = (map: GoogleMapReact, maps: any) => {
const HQMarker = function (lat, lng) {
this.lat = lat;
this.lng = lng;
this.pos = new maps.LatLng(lat, lng);
};
HQMarker.prototype = new maps.OverlayView();
HQMarker.prototype.onAdd = function () {
// here is the solution -->
const container = document.createElement('span');
const root = createRoot(container);
root.render(<HQMarkerTemplate />);
const panes = this.getPanes();
panes.overlayImage.appendChild(container);
};
HQMarker.prototype.draw = function () {
var overlayProjection = this.getProjection();
var position = overlayProjection.fromLatLngToDivPixel(this.pos);
var panes = this.getPanes();
panes.overlayImage.style.left = position.x + "px";
panes.overlayImage.style.top = position.y - 20 + "px";
};
new HQMarker(endPoint.lat, endPoint.lng).setMap(map);
};
...
...
...
return (
<GoogleMapReact
yesIWantToUseGoogleMapApiInternals
onGoogleApiLoaded={({ map, maps }) => handleApiLoaded(map, maps)}
options={...}
/>
)
}
from google-map-react.
@HelloNeptune from where is endPoint coming?
from google-map-react.
@HelloNeptune from where is endPoint coming?
Its just an object which contains lat and lng fields
from google-map-react.
@HelloNeptune from where is endPoint coming?
Its just an object which contains lat and lng fields
I do understand that but it not defined anywhere else, it is throwing error at my end, endPoint is undefined
from google-map-react.
@HelloNeptune from where is endPoint coming?
Its just an object which contains lat and lng fields
I do understand that but it not defined anywhere else, it is throwing error at my end, endPoint is undefined
You can use your own values 👍
from google-map-react.
Related Issues (20)
- map.getProjection(...).fromContainerPixelToLatLng is not a function HOT 4
- Google map suddenly stopped loading, white screen appears. HOT 1
- Map Pins are not positioned correctly after zoom or pan HOT 12
- Fitbounds and directionService is not updating markers on the map HOT 1
- Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'm.nB')
- Card with address on upper left corner
- drag the map when we hover on div card outside the map and it show the that particular marker if marker is hide on centre coardinates HOT 1
- Google together with Visgl and OpenJS has released the official react components for Google maps HOT 4
- need to detect getVisible StreetViewService
- AdvancedMarkerElement HOT 2
- Creating a map marker with visgl library
- React.StrictMode throws warning because of findDOMNode use HOT 3
- React 18 StrictMode: Markers incorrectly positioned HOT 2
- Error: ENOENT: no such file or directory, open @googlemaps\src\index.ts
- Marker not showing, using React 18 HOT 2
- Trouble Implementing Content Security Policy (CSP) with Google Maps and Google Tag Manager in React Project
- AdvancedMarker onDragEnd event causes Map's onClick event to fire
- this.Eg.close() is not a function Error. HOT 1
- Add support for new CameraControl introduced in Maps 3.58 HOT 3
- Update dependencies, esp @googlemaps/js-api-loader
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-map-react.