-
-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from mfazekas/images-comp
Introduce Images, and deprecate ShapeSource#images
- Loading branch information
Showing
8 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { viewPropTypes } from '../utils'; | ||
import ShapeSource from './ShapeSource'; | ||
|
||
/** | ||
* Images defines the images used in Symbol etc layers | ||
*/ | ||
class Images extends React.Component { | ||
static propTypes = { | ||
...viewPropTypes, | ||
|
||
/** | ||
* Specifies the external images in key-value pairs required for the shape source. | ||
* If you have an asset under Image.xcassets on iOS and the drawables directory on android | ||
* you can specify an array of string names with assets as the key `{ assets: ['pin'] }`. | ||
*/ | ||
images: PropTypes.object, | ||
}; | ||
|
||
_getID() { | ||
if (!this.id) { | ||
this.id = `${ShapeSource.imageSourcePrefix}-${Math.random().toString(36).substr(2,9)}` | ||
} | ||
return this.id; | ||
} | ||
|
||
render() { | ||
const id = this._getID(); | ||
|
||
return ( | ||
<ShapeSource | ||
images={this.props.images} | ||
id={id} | ||
shape={{ | ||
"type": "FeatureCollection", | ||
"features": [] | ||
}} | ||
> | ||
{this.props.children} | ||
</ShapeSource> | ||
); | ||
} | ||
} | ||
|
||
export default Images; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters