Javascript API Quickstart Guide
As a way to jump start your ability to place a map on the page, the following step by step guide will provide the very basic entry point for a Micello Map.
- Include the <!DOCTYPE HTML> tag at the very top of your page. (if you interested in understanding why, you can go here)
-
Between the <head>and</head> tags, include the following line of code:
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
-
Between the <head>and</head> tags, include the following line of code:
- <script type="text/javascript" src="http://maps.micello.com/webmap/v0/micellomap.js"></script>
-
Just below the line of Javascript you added in Step 2, add the following block of Javascript (again still working between the "head" tags).
Where you see YOUR_API_KEY, replace that text with the API key Micello provided for you. (Don't have one?)
Where you see COMMUNITY_ID you will need to provide the ID that Micello assigns for each Community. You can find the ID on the Community Place page.
- <script type="text/javascript">
- micello.maps.init(YOUR_API_KEY,mapInit);
- function mapInit() {
- var mapControl = new micello.maps.MapControl('mapElement');
- var mapDataObject = mapControl.getMapData();
- mapDataObject.loadCommunity(COMMUNITY_ID);
- }
- </script>
-
Right below the Javascript you added in Step 3, add the following lines (which will provide the ability to give the map a height and a width).
Where you see YOUR_WIDTH, replace that text with the number of pixels you want the map to be wide. (For example, if you wanted your map to be 400 pixels wide, you would replace YOUR_WIDTH with 400px)
Where you see YOUR_HEIGHT, replace that text with the number of pixels you want the map to be wide. (For example, if you wanted your map to be 400 pixels wide, you would replace YOUR_HEIGHT with 400px)
- <style type="text/css">
- #mapElement {width:YOUR_WIDTH; height:YOUR_HEIGHT;}
- </style>
-
And finally, between the "body" tags on your page, paste the following:
- <div id="mapElement"></div>
Now if we put it all together into a working example, you can see how each of the pieces on the page fit together. (You can download this HTML example at the bottom of the page as well)
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Map View</title>
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <script type="text/javascript" src="http://maps.micello.com/webmap/v0/micellomap.js"></script>
- <script type="text/javascript">
- micello.maps.init("9a3f7c80620897a31a61",mapInit);
- function mapInit() {
- var mapControl = new micello.maps.MapControl('mapElement');
- var mapDataObject = mapControl.getMapData();
- mapDataObject.loadCommunity(78);
- }
- </script>
- <style type="text/css">
- html, body { height: 100%; width: 100%; margin: 0; overflow:hidden;}
- #mapElement {width:100%; height:100%;}
- </style>
- </head>
- <body>
- <div id="mapElement"></div>
- </body>
- </html>


