Mootools and the StaticMaps library are described in HTML in the head element.
<head> <script type="text/javascript" src="mootools-core1.3.js"></script> <script type="text/javascript" src="StaticMaps.js"></script> <script type="text/javascript" src="StaticMaps.Position.js"></script> <script type="text/javascript" src="StaticMaps.Marker.js"></script> <script type="text/javascript" src="StaticMaps.Path.js"></script> </head>
The container element that draws in the map is described.
<div id="staticMap"></div>
It draws in the map in the element that specifies the parameter necessary for the option, executes the renderTo method, and specifies it.
window.addEvent('domready', function(){ var map = new StaticMaps({ position: { center: {lat: 35.710698, lng: 139.81257}, zoom: 15 }, map: { size: { width: 600, height: 300 }, format: 'jpg', mapType: 'roadmap', mobile: true, language: 'en' }, markers: [ { color: '0xCCCCCCC', size: 'mid', label: 'A', point: 'New York' }, { color: '0xFFCCCCC', size: 'mid', label: 'B', point: {lat: 40.714353, lng: -74.005973} } ], path: { color: '0xFF0000', points: [ 'New York', { lat: 40.714353, lng: -74.005973 } ] } }); map.renderTo($('staticMap')); });
Moreover, it is also possible to specify it individually by using the method of the setter.
window.addEvent('domready', function(){ //It draws specifying the condition in the map. var map = new StaticMaps(); map.setSize(600, 300) .setCenter({ lat: 35.710698, lng: 139.81257 }) .setZoom(15); map.addMarker({ color: '0xCCCCCCC', size: 'mid', label: 'A', point: 'New York' }); var marker = map.factory('marker', { color: '0xCCCCCCC', size: 'mid' }); marker.setLable('B') .setPoint({ lat: 40.714353, lng: -74.005973 }); map.addMarker(marker); map.renderTo($('staticMap')); //A new map is added. var url = map.toQueryString(); var img = new Element('img', { src: url }); img.inject($('staticMap')); });
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus