Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am a pure beginner of openlayers, I have a KML data coming from the database which describes all the cordinates of zip code 45050, I would like to draw these coordinates onto openlayers map as boundaries and I want it colored as well. I am not pretty sure that my KML data is appropriate. Is there any easy way to do so? if so would you expose the solution.

Here is my KML data: -84.3398,39.4274,0 -84.3535,39.4283,0 -84.3539,39.4239,0 -84.3589,39.4241,0 -84.3661,39.4256,0 -84.3658,39.4287,0 -84.3838,39.4298,0 -84.3834,39.4336,0 -84.3783,39.4333,0 -84.3786,39.4338,0 -84.3836,39.437,0 -84.3941,39.4376,0 -84.3985,39.4418,0 -84.3932,39.4571,0 -84.393,39.465,0 -84.3934,39.4738,0 -84.389,39.4714,0 -84.39,39.4666,0 -84.3725,39.4679,0 -84.3649,39.4644,0 -84.3536,39.4632,0 -84.3527,39.464,0 -84.3491,39.4622,0 -84.337,39.4521,0 -84.337,39.4521,0 -84.3398,39.4274,0

share|improve this question
    
That is not KML. –  CaptDragon Jan 17 '13 at 21:40
add comment

1 Answer 1

Here is an example of what you are looking for.

To use it, choose KML as the format, paste your kml into the box, and click "add feature". You will see the kml is fine as I have it below:

<kml xmlns="http://earth.google.com/kml/2.0">
    <Folder>
        <name>OpenLayers export</name>
        <description>Exported on Thu Jan 17 2013 16:40:09 GMT-0500 (Eastern Standard Time)</description>
        <Placemark>
            <name>OpenLayers.Feature.Vector_116</name><description>No description available</description>
            <Polygon><outerBoundaryIs><LinearRing><coordinates>-84.3398, 39.4274 -84.3535, 39.4283 -84.3539, 39.4239 -84.3589, 39.4241 -84.3661, 39.4256 -84.3658, 39.4287 -84.3838, 39.4298 -84.3834, 39.4336 -84.3783, 39.4333 -84.3786, 39.4338 -84.3836, 39.437 -84.3941, 39.4376 -84.3985, 39.4418 -84.3932, 39.4571 -84.393, 39.465 -84.3934, 39.4738 -84.389, 39.4714 -84.39, 39.4666 -84.3725, 39.4679 -84.3649, 39.4644 -84.3536, 39.4632 -84.3527, 39.464 -84.3491, 39.4622 -84.337, 39.4521 -84.337, 39.4521 -84.3398, 39.4274</coordinates></LinearRing></outerBoundaryIs></Polygon>
        </Placemark>
</Folder>
</kml/>
share|improve this answer
    
thanks for your response, now how do I get the js code to implement this and draw it? how do I change the color?for instance I have 2 or multiple zip codes and I want to draw them in different colors –  Alaa Osta Jan 18 '13 at 13:21
    
The code to implement it is in the example, please view source. You can change the color by using the feature styles. Many ways to do it. Please refer to the styling guide. –  CaptDragon Jan 18 '13 at 15:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.