Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-google-maps
Advanced tools
React.js Google Maps integration component
Declare your Google Maps components using React components.
import {GoogleMap, Marker} from "react-google-maps";
export default function SimpleMap (props) {
return (
<section style={{height: "100%"}}>
<GoogleMap containerProps={{
style: {
height: "100%",
},
}}
defaultZoom={3}
defaultCenter={{lat: -25.363882, lng: 131.044922}}
onClick={props.onMapClick}
>
{props.markers.map((marker, index) => {
return (
<Marker
{...marker}
onRightclick={() => props.onMarkerRightclick(index)} />
);
})}
</GoogleMap>
</section>
);
}
Define <GoogleMap>
component in the top level. Use containerProps
, containerTagName
to customized the wrapper DOM for the component.
Other components like <Marker>
belongs to the children of <GoogleMap>
. You already know this from the example code above.
Everything in the Methods
table in the official documentation of the component could be set via component's props directly. For example, a <Marker>
component has the following props:
animation, attribution, clickable, cursor, draggable, icon, label, opacity, options, place, position, shape, title, visible, zIndex
Every props mentioned in Rule 2 could be either controlled or uncontrolled property. Free to use either one depends on your use case.
Anything that are inside components' options
property could ONLY be accessible via props.options
. It's your responsibility to manage props.options
object during the React lifetime for your component. My suggestion is, always use Rule 3 if possible. Only use options
when it's necessary.
One common event trigger is to resize map after the size of the container div changes:
componentDidUpdate() {
var map = ReactDOM.findDOMNode(this.refs.map);
window.google.maps.event.trigger(map, 'resize');
}
<GoogleMap {...props} ref="map" > ... </GoogleMap>
Static hosted demo site on GitHub. The code is located under examples/gh-pages folder.
react-google-maps
requires React 0.14
npm install --save react-google-maps
All components are available on the top-level export.
import { GoogleMap, Marker, SearchBox } from "react-google-maps";
You could of course import from individual modules to save your webpack's bundle size.
import GoogleMap from "react-google-maps/lib/GoogleMap"; // Or import {default as GoogleMap} ...
Some addons component could ONLY be accessible via direct import:
import InfoBox from "react-google-maps/lib/addons/InfoBox";
First, clone the project.
git clone ...
Install docker@^1.8.2
, docker-compose@^1.4.0
and optionally docker-machine@^0.4.1
. Then,
docker-compose run --service-ports web
Then open http://192.168.59.103:8080.
192.168.59.103 is actually your ip from docker-machine ip
.
If you change code in your local, you'll need to rebuild the image to make changes happen.
If you're previously using boot2docker
, you may want to migrate to docker-machine instead.
docker-compose build
Install node
. Then,
npm install
cd examples/gh-pages
npm install
npm start
Then open http://localhost:8080/webpack-dev-server/.
Install node
. Then,
npm install
cd examples/gh-pages
npm install
npm start:windows
Then open http://localhost:8080/webpack-dev-server/.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
React.js Google Maps integration component
The npm package react-google-maps receives a total of 118,370 weekly downloads. As such, react-google-maps popularity was classified as popular.
We found that react-google-maps demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.