Dynamic loading of KML placemarks on Google maps

I have a static .csv type file that lists 4000+ addresses, each with a unique id, and their correlative latitude and longitude. I want to query a database that has events stored for each venue id and then display on a Google map, only those addresses that have events that match the query.

This would be one thing if it were not for Google's query limit (when it goes live, there is the potential for hundreds of thousands to millions of queries daily). The limit for KML files is sufficient, however (I believe it is only file size that is counted, am I wrong?) and I would just convert the .csv type file to a .kml file were it not for the fact that I don't want all 4000+ addresses to be loaded on the map every time, only those that correspond to the search query.

There has to be a way of selectively loading certain placemarks from a single .kml file, right? I would like to not need to use a server side approach (ASP.Net) if possible, but will if absolutely necessary.

~~~~~

I think I'll use the server side approach. I would still like to use kml as I was running into the query limit trying pure JavaScript (although I may have been doing something wrong then as that was when I was just learning how to use the Google maps API). The kml consists of venues and their relevant location for events one might have to buy tickets to. A search term might be 'wicked New York', or 'concerts FL'. The database will return venue id's, which correlate to placemark id's in the kml file. What I would like to do is use an array of venue id's that are returned by the search query and then scan through the kml file and return only those placemark id's that match the venue id's in the array. I would then like to have the kml placemarks be loaded into a div tag in on same page and then have this be what Google uses to put the pointers on the map. Is there a way of using # named anchors instead of complete URL's to load the kml into Google maps (var kmlVar = new google.maps.KmlLayer('#kmlDivTagOnSamePage'); this doesn't work)? This would then be easy to write the server side ASP part.


If you are just using 2D maps, there is probably no need to use KML. And since you don't need to display all 4k locations at once, you probably don't need to use Google's server side rendering (you can just render the markers in javascript), so although Fusion Tables could work I'd instead recommend one of these alternatives: - Loading up all the data as a JSON dictionary with the ids as your key, and when a search is run, find the matches and just display those - Don't load anything on the client initially: Just query your server and have it return all the data you need for display for each search

If these suggestions don't seem to make sense, perhaps try provide the exact type of query someone might ask, and what type of response you expect from the database, whether you control that database, etc.

链接地址: http://www.djcxy.com/p/23346.html

上一篇: 显示一个gpx文件的地图

下一篇: 在Google地图上动态加载KML地标