Note, there are major changes to the API starting with version 3.0. More info.
Because our HTML5 maps are built using JavaScript and SVG, it is possible to manipulate the map in real time using JavaScript. We have put together an API to make it easy to communicate with our map by calling JavaScript functions. The API makes it possible for the map to communicate and interact with other elements on the page.
Edit the properties of the map
Edit the simplemaps_worldmap_mapdata object using JavaScript. For example:
To change the width of the map:
simplemaps_worldmap_mapdata.main_settings.width=500;
To change the color of a state:
simplemaps_worldmap_mapdata.state_specific['GA'].color='red';
To change the description of a location:
simplemaps_worldmap_mapdata.locations[0].description='New';
Update the map with one of two functions
Load or reload the map. This will create or recreate the map. Slower.
simplemaps_worldmap.refresh()
Refresh the map. This updates the map properties (colors etc.) but does not redraw the map. Very fast.
It's possible to use JavaScript to zoom around the map.
simplemaps_worldmap.state_zoom(state_id, callback) Zoom the map to a state by id. callback is optional. |
|
simplemaps_worldmap.region_zoom(region_id, callback) Zoom the map to a region by id. callback is optional. |
|
simplemaps_worldmap.location_zoom(location_id, zoom_percentage, callback) Zoom the map to a location by id. callback is optional. zoom_percentage is the size of the viewbox relative to location size (4 by default). Requires: main_settings.manual_zoom: "yes",. |
|
simplemaps_worldmap.back(callback) Zooms out. Equivalent to clicking the back arrow in the map. callback is optional. |
|
simplemaps_worldmap.zoom_level Tells you the current zoom level of the map. ('out', 'region', 'state') |
simplemaps_worldmap.state_zoom("ID"); //Zoom to state by id
simplemaps_worldmap.region_zoom("0"); //Zoom to region by id
simplemaps_worldmap.region_zoom("0", function(){ alert("Zoom done")} ); //Zoom and callback when complete
simplemaps_worldmap.location_zoom('0', '4');
simplemaps_worldmap.popup(type, id) | Open a popup/tooltip programmatically. Type can be ['location', 'state', 'region']. Example: simplemaps_worldmap.popup('location', '0') |
simplemaps_worldmap.popup_hide() | Hides any open popup |
create_simplemaps_worldmap() | create a map instance with its own name. Example: var map1=create_simplemaps_worldmap(); |
map_instance.mapdata | mapdata is bound to each map instance. Example: map1.mapdata.main_settings.state_color='red'; |
simplemaps_worldmap.refresh_state(id) | Allows you to refresh a single state by id to more efficiently update the map. |
simplemaps_worldmap.get_xy() | Allows you to click on the map to get any point's x and y coordinates. Useful for labels. |
simplemaps_worldmap.calibrate() | Provides an object containing the bounding box for every state. Needed by the mapinfo object if you add new states to the map. |
At times, it is useful to load the map manually, instead of allowing the map to load itself after the page has loaded. To load the map manualy:
Home | License | Privacy | Releases | Testimonials | Resources | Documentation | Order Lookup | All Maps | FAQs
Formerly FlashUSAmap.com and FlashWorldMap.com
SimpleMaps.com is a product of Pareto Software, LLC. © 2010-2024.