In a nutshell, Our Custom Element Should
So, the purpose of our custom element in essence means, If you pass an array of locations like so:
<g-map location-array='["Norway","Sweden"]'></g-map>
The custom element
First, Let us import whatever we need into our element.This element is under
elements/g-map.html
<link rel=import href="../bower_components/google-map/google-map.html"> <link rel=import href="../bower_components/google-map/google-map-marker.html"> <link rel=import href="../bower_components/google-map/google-map-search.html"> <link rel=import href="../bower_components/google-map/google-map-directions.html">
Note
Some of the above imports, aren’t necessary, but good to have, in case you fancy add on functionality on your markers
We necessarily need,
- google-map
- google-map-marker
- google-map-search
Also, It is presumed, you know how to install the individual Polymer Elements Via Bower
Next, we register our custom element as “g-map”
Polymer({ is:"g-map" });
So! our custom element is registered with Polymer.
We will add google map search specific properties and any other properties we need, later.
Next, we add the template for our custom element
Open up elements/g-map.html, and add a template that binds the custom elements DOM
<template id="google-map-with-search"> </template>
Now, wrap the entire html and javascript you wrote for our custom element, inside of a dom-module.
<dom-module id="g-map"> <template id="google-map-with-search"> </template> <script> Polymer({ is:"g-map", properties: {} }); </script> </dom-module>
Very Nice! We have a basic blueprint