JavaScript API

GeoIQ supports a developer friendly JavaScript API for integrating data and visualizations into web pages and applications. If you want to walk through the examples go to http://sandbox.geoiq.com/walk_through.html with Firefox and you can paste the examples into the console.

Includes

To begin using the GeoIQ JavaScript, you must first include the API library. If you are developing using the public GeoCommons community, you would include the API from the GeoCommons server:

<script src=”http://geocommons.com/javascripts/f1.api.js” type=”text/javascript”></script>

However, if you are developing on a different GeoIQ server then you should include the library from the server that you are developing with. This is because the server will be searched based on where the library is loaded. Alternatively, you can set F1.host to the server you are developing with. For example:

<script src=”http://geocommons.com/javascripts/f1.api.js” type=”text/javascript”></script>
<script type="text/javascript" charset="utf-8">
F1.host = “http://demo.geoiq.com”;
var geoiq_map = new F1.Maker.Map({map_id: "78378", dom_id: "map_div"});
</script>

Embed map

Usually the easiest way to get started with the GeoIQ JavaScript API is to first embed a map. You can then easily expand your integration from there. The example below

<style>#map_div {width: 600px; height: 400px;}</style>
<div id="map_div"></div>
<script type="text/javascript" charset="utf-8" src="http://geocommons.com/javascripts/f1.api.js"></script>
<script type="text/javascript" charset="utf-8">
var geoiq_map = new F1.Maker.Map({map_id: "78378", dom_id: "map_div"});
</script>

Learn more

 

Comments are closed.