我目前正在使用 google-maps-react 进行 google-maps 项目,但遇到了一个问题。我正在使用道具来获取我的标记的值(纬度、经度、标记图标),但是我无法更改标记的大小。我留下了一个巨大的标记,无法改变这一点。我试图将尺寸作为道具传递,但没有成功。
预先感谢您的任何帮助。
这是我的代码:
MAPS.JS
render() {
/*--- initial code that i passed into props*/
/*var icon = {
url: "https://loc8tor.co.uk/wp-content/uploads/2015/08/stencil.png", // url
scaledSize: new this.props.google.maps.Size(90, 42), // scaled size
*/
}
return (
<div className="map-container">
<Map
google={this.props.google}
className={"map"}
zoom={4}
initialCenter={this.props.center}
>
{this.props.places.map((place, i) => {
//pass an array of markers as a child to the GoogleMap component and map over them
return (
<Marker
onClick={this.onMarkerClick}
key={place.id}
place_={place}
position={{ lat: place.lat, lng: place.lng }}
icon={place.url}
//Size={place.scaledSize} : Not working
/>
);
})}
<InfoWindowEx
marker={this.state.activeMarker}
visible={this.state.showingInfoWindow}
>
<div>
<h3>{this.state.selectedPlace.name}</h3>
<button
type="button"
onClick={this.showDetails.bind(this, this.state.selectedPlace)}
>
Show details
</button>
</div>
</InfoWindowEx>
</Map>
</div>
);
索引.JS
import React from "react";
import ReactDOM from "react-dom";
import Map from "./Map";
import "./styles.css";
const data = [
{
name: "Hello",
title: "Sydney",
lat: -33.847927,
lng: 150.6517938,
id: 1,
color: "blue",
url: "https://loc8tor.co.uk/wp-content/uploads/2015/08/stencil.png",
// scaledSize: Size(90, 42), // scaled size - Not working//
},
{