1

I want to use the Wikimapia API.

  1. What format should I choose to easily get polygon coordinates from it?
  2. How can I get the coordinates and the place names of the file?
  3. How can I make a variable from API output?

I want to draw polygons in Maps API with this informations.

creemama
  • 6,559
  • 3
  • 21
  • 26

1 Answers1

1
  1. Which format is the best to use depends mostly how you use the data after. For a Website whit JavaScript jsonp is probably the best choice (I guess Maps API is the one from Google). Don't use json as this is restricted because the json come from a different server than your JavaScript.
  2. The first x coordinate is here: your_data_object.folder[0].polygon[0].x
  3. You will get directly a JavaScript object.

Example:

<script type="text/javascript" >

var apikey = "YOUR API KEY";
var request = "http://api.wikimapia.org/?function=box&bbox=99.555,1.2,104.353,6.751&category=88&count=2&format=jsonp&jsoncallback=readwikimapia&key="+apikey;

// Callback defined in the URL.
// This function is run by the code from WikiMapia
function readwikimapia(data){
 document.write(data.folder[0].polygon[0].x);
}

// Create a script object to load the jsonp script
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = request;
document.body.appendChild(script);

</script>
Den
  • 547
  • 1
  • 6
  • 15