0.0.5 • Published 10 years ago
ember-cli-mapy-cz v0.0.5
Ember-cli-mapy-cz
An ember-cli add-on for easy integration with mapy.cz maps. Each object displayed on map is inserted via child component, so you can easily declare which marker and when to display on map using {{#if}} and {{#each}} on template level.
Installation
ember install ember-cli-mapy-cz
Configuration
You must define the size of the canvas in which the map is displayed in your application. Otherwise the map will have zero size. Simply add something similar to this to your styles:
.s-map {
width: 640px;
height: 480px;
}Usage
Simple map
{{s-map latitude=37.7833 longitude=-122.4167 zoom=12}}Map with markers
- Create block version of
s-mapcomponent. You can pass itstyleattribute for in-line styling - Inside
s-mapcomponent creates-map-layer. Currently this has no great use. Mainly for future usage. - Inside
s-map-layercomponent create as manys-map-markercomponents as you want. Just pass in latitude and longitude. Use decimal degrees formatmarker: {latitude: 40.446, longitude: 79.982}
{{#s-map latitude=latitude longitude=longitude zoom=zoom style="width: 100%" as |map|}}
{{#s-map-layer map=map as |layer|}}
{{#each points as |point|}}
{{s-map-marker layer=layer latitude=marker.latitude longitude=marker.longitude}}
{{/each}}
{{/s-map-layer}}
{{/s-map}}Map with markers and cards
- Create
s-map-cardcomponent and pass its-map-markerreference. - If you use
s-map-cardas a block, this block will be used forbody. - If you use
s-map-cardin non-block version, thenbodyproperty will be used forbody. - You can always use
titleproperty to settitleof the card. - If no title is provided, the card won't have one.
{{#s-map latitude=latitude longitude=longitude zoom=zoom style="width: 100%" as |map|}}
{{#s-map-layer map=map as |layer|}}
{{#each points as |point|}}
{{#s-map-marker layer=layer latitude=point.latitude longitude=point.longitude as |marker|}}
{{#if point.cardBody}}
{{#s-map-card marker=marker header=point.cardHeader}}
This is block version for the body of the card. We can pass dynamic arguments here: {{point.cardBody}}
{{/s-map-card}}
{{else}}
{{s-map-card marker=marker title="Empty card" body="This card has only static text."}}
{{/if}}
{{/s-map-marker}}
{{/each}}
{{/s-map-layer}}
{{/s-map}}Running
ember server- Visit your app at http://localhost:4200.
Running Tests
npm test(Runsember try:testallto test your addon against multiple Ember versions)ember testember test --server
Building
ember build
For more information on using ember-cli, visit http://ember-cli.com/.
Thanks
- Major ideas in this project comes from ember-g-map project.
- Special shout out goes to Geret