Reputation: 19815
I have 100 coordinates (latitude, longitude). I want to produce a static image (png, pdf) or if possible, interactive interface (in a browser) to show these points on the world map.
I am thinking Google Map's might have an API for this, however I haven't used anything like that before. So, not sure where/what to look for. Can you give me some keywords/links/code samples?
Upvotes: 0
Views: 5265
Reputation: 11039
You can do something similar to this using Google Maps:
var map
function initialize() {
var mapOptions = {
// map options
};
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
var coordinates = [{latitude: 42, longitude: 42, title: "A Title"},...]
for(var i = 0; i < coordinates.length; i++){
var loc = new google.maps.LatLng(coordinates[i].latitude, coordinates[i].longitude);
var marker = new google.maps.Marker({
position: loc,
map: map,
title: coordinates[i].title
});
}
How exactly you get the coordinate data to your template is another issue but it can be done pretty easily with AJAX using Flask or Django (or any other web framework but I am most familiar with those 2).
And for your template:
<head>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR-KEY"></script>
</head>
<div id="map-canvas"></div>
Upvotes: 2
Reputation: 818
Upvotes: 1