-
Notifications
You must be signed in to change notification settings - Fork 936
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
Pick up a script loader and provide as a optional Compoent #92
Comments
+1. I've been using react-async-script for loading googlemaps API and it worked fine before I updated to react-google-maps v2. I'm against adding a script tag to load googlemaps API, it's against reactjs's modular structure, so I think react-google-maps itself should provide a way to load googlemaps API or at least play well with 3rd party async script loaders. |
Thanks for the info of |
Hey! Any progress on this? |
How is this progressing? |
Okay. Right now I could add another BranchScreenshotThe error in the web console shows that async loaded google.maps script will fail due to Reason for thatWe use 11/16/2015 UpdateReleases |
Guys, I've added a new component called Please check it out and let me know any issues, thanks! You can use the version of 4.3.1 |
Using the async script loading internally does not expose important constants like MapTypeId.TERRAIN to map parent component. It makes it unconvenient to set up the map. Could the default options be set via callback that recieves the maps api reference after loading? |
@tstavinoha consider using the |
* Closes #145 * Ref #92 BREAKING CHANGE: rename from async/ScriptjsGoogleMap to async/ScriptjsLoader and changed behavior from wrapping to delegation of GoogleMap element To migrate the code follow the example below (extracted from examples/gh-pages migration): Before: <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.${ AsyncGettingStarted.version }`, libraries: "geometry,dr awing,places"}} } // <GoogleMap> props defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this._handle_map_click} /> After: <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.${ AsyncGettingStarted.version }`, libraries: "geometry,drawing,places"}} googleMapElement={ <GoogleMap defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this._handle_map_click} /> } />
* Mark async/ScriptjsGoogleMap as deprecated * Closes #145 * Ref #92 BREAKING CHANGE: migrate from async/ScriptjsGoogleMap to async/ScriptjsLoader and changed its behavior from implicit inheritance to simple delegation To migrate the code follow the example below (extracted from examples/gh-pages migration): Before: <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.exp`, libraries: "geometry,dr awing,places"}} } // <GoogleMap> props defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this._handle_map_click} /> After: <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.exp`, libraries: "geometry,drawing,places"}} googleMapElement={ <GoogleMap defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this._handle_map_click} /> } />
* Mark async/ScriptjsGoogleMap as deprecated * Closes #145 * Ref #92 BREAKING CHANGE: migrate from async/ScriptjsGoogleMap to async/ScriptjsLoader and changed its behavior from implicit inheritance to simple delegation To migrate the code follow the example below (extracted from examples/gh-pages migration): Before: ```js <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.exp`, libraries: "geometry,drawing,places"}} // // <GoogleMap> props defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this._handle_map_click} /> ``` After: ```js <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.exp`, libraries: "geometry,drawing,places"}} // googleMapElement={ <GoogleMap defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this._handle_map_click} /> } /> ```
* Mark async/ScriptjsGoogleMap as deprecated * Closes #145 * Ref #92 BREAKING CHANGE: migrate from async/ScriptjsGoogleMap to async/ScriptjsLoader and changed its behavior from implicit inheritance to simple delegation To migrate the code follow the example below (extracted from examples/gh-pages migration): Before: ```js <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.exp`, libraries: "geometry,drawing,places"}} // // <GoogleMap> props defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this._handle_map_click} /> ``` After: ```js <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.exp`, libraries: "geometry,drawing,places"}} // googleMapElement={ <GoogleMap defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this._handle_map_click} /> } /> ```
* Ref #92 BREAKING CHANGE: ScriptjsLoader will delegate to GoogleMapLoader when the script is loaded Before: ```js <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.${ AsyncGettingStarted.version }`, libraries: "geometry,drawing,places"}} loadingElement={ <div {...this.props} style={{ height: "100%" }}> <FaSpinner /> </div> } googleMapElement={ <GoogleMap containerProps={{ ...this.props, style: { height: "100%", }, }} ref={googleMap => { // Wait until GoogleMap is fully loaded. Related to #133 setTimeout(() => { googleMap && console.log(`Zoom: ${ googleMap.getZoom() }`); }, 50); }} defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this.handleMapClick} > <Marker {...this.state.marker} onRightclick={this.handleMarkerRightclick} /> </GoogleMap> } /> ``` After: ```js <ScriptjsLoader hostname={"maps.googleapis.com"} pathname={"/maps/api/js"} query={{v: `3.${ AsyncGettingStarted.version }`, libraries: "geometry,drawing,places"}} loadingElement={ <div {...this.props} style={{ height: "100%" }}> <FaSpinner /> </div> } containerElement={ <div {...this.props} style={{ height: "100%" }} /> } googleMapElement={ <GoogleMap ref={googleMap => { googleMap && console.log(`Zoom: ${ googleMap.getZoom() }`); }} defaultZoom={3} defaultCenter={{lat: -25.363882, lng: 131.044922}} onClick={::this.handleMapClick} > <Marker {...this.state.marker} onRightclick={this.handleMarkerRightclick} /> </GoogleMap> } /> ```
Close for now. We're also looking for maintainers. Involve in #266 to help strengthen our community! |
Why
Inspired by #81 , I think it would be great if we could provide a
<Component>
that will load this module.Candidates
https://tomchentw.github.io/xrossref/#ZG96b2lzY2gvcmVhY3QtYXN5bmMtc2NyaXB0LCBzeXN0ZW1qcy9zeXN0ZW1qcywgZGVkL3NjcmlwdC5qcywgU2xleEF4dG9uL3llcG5vcGUuanMsIGdldGlmeS9MQUJqcywgd2Vzc21hbi9kZWZlci5qcw==
Thoughts
Since
System.js
seems to be the best, future proof library ATM, I think it would be great to implement this feature with it. However, it seems to be too overkilled for a simple feature to use ~13KB in minified, ungzipped bundle.I was thinking if we could provide a tiny polyfill when
System
is not exist:Is this polyfill matches what System.js do? Or will there be any problem associate with it?
References
The text was updated successfully, but these errors were encountered: