I am very new to openlayers, I want to make some countries already selected (with some color filled on the selected areas) when i open my page. I am using the GML layer with kml file as i开发者_开发技巧nput. But still it doesn't seems like a perfect solutions to me. I am assuming i already have kml file which contains the boundary coordinates. Can some one help me to find this solution? if this is not the correct way please suggest me. I highly appreciate for any suggestions. Thanks in advance.
if you have geodjango and country data on your database you can do this as below :
django view.py
clickedPoint = Point(x,y,srid = 4326)
whichCountry = CountryPolyon.objects.filter(the_geom__contains = clickedPoint)
then you can take geojson and u can add your map the country polygon. the last thing you must do is add the code of remove first polygon
map.vector.removeFeatures(map.vector.features);
it may be a long way but usefull way...hope you like it
This example select some areas on mouse over. Maybe looking the source you can change the behaviour to select some areas on load the map.
精彩评论