NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


I am using OpenLayers and Open Street Maps API,to display the Maps.and I am able to successfully show Maps,Pins,and the Popups when the User clicks on Pins.However I have a new requirement to represent the States in USA with some colors .

Is it possible using Open Street Maps API?

Please guide me to any articles ,if anyone have .

Thanks everyone

asked 14 Nov '11, 12:42

VenuGopal's gravatar image

accept rate: 0%

No, not with the API.

There are many ways how one could achieve what you say, and recommending something would require knowing more about the exact use cases of your application. However I guess it is most likely that you will want to prepare a KML file with the polygons for US states, and have that displayed in OpenLayers. This is relatively simple, technology-wise.

You could extract the boundaries from OSM but that would probably be too much information for you (too much data to display in the browser at a zoomed-out level). Therefore I guess your best option would be finding KML files for state borders elsewhere - plenty around - or download them in Shapefile form from and convert to KML with a free tool like QGis.

permanent link

answered 14 Nov '11, 13:16

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

Hi Fredrik,

Thanks for your reply,My Application would involve something like ,

I will have Sales figures for each state

if my Sales are <20-represent that state as red ,>30-<70=yellow and >80 =Green.

if two states side by side having the same colore even though,when I hover the mouse I should be able to identify .I dont have any idea about KML File,Can you provide me any guide to KML File?I am looking for something like

(15 Nov '11, 11:18) VenuGopal

Download and install Quantum GIS. That's a free GIS package that allows you to view the shape files from Natural Earth Data, and also export them as KML files. The file that you listed is countries only; if you want states you will have to go to . Once you have KML files you can display them in OpenLayers and you can also highlight clicked areas but this will require a thorough understanding of OpenLayers (search the web for "openlayers kml polygons").

(15 Nov '11, 12:20) Frederik Ramm ♦

Hi Fredrik, Thanks for your response,I am able to make progress. I downloaded and Installed the QGIS tool to covert the Shape File to KML File. I would like to create a Choropleth map or heat map from this KML File,based on my input sales figures,Do you have any article to develop a choropleth map from KML file?

I am getting an Object Expected error when I am using as below var myvectorlyr= new OpenLayers.Layer.Vector("KML", { projection: map.displayProjection, strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "kml/MyStates.kml", format: new OpenLayers.Format.KML({ extractStyles: true, extractAttributes: true }) }) }); map.addLayer(myvectorlyr);

I am using the API as <script src=""></script>

(16 Nov '11, 13:24) VenuGopal

I am able to plot the states using the KML file,However the colors are getting the default one all the time,even though I specify some color in the KML file .and I cleared the cache and tried.still that is not working,Any way we can see the specified color in the KML file Thanks Fredrik

(18 Nov '11, 06:09) VenuGopal

When I loaded that KML file in QGIS tool,I am able to see the color for that state in this Tool,However when I am loading this file with OSM Api in html,I am seeing only the Orange Color always

(18 Nov '11, 11:31) VenuGopal

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 14 Nov '11, 12:42

question was seen: 14,963 times

last updated: 18 Nov '11, 11:31

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum