开发者

Markers: Database vs XML

I want Google Maps markers that will:

  • Change on a daily basis
  • Be load开发者_开发技巧ed depending on (if there is an event at particular venue tonight)
  • Loaded Categorically (can be turned on/off)
  • loaded by date

I expect to have an average of 40 markers on screen at a time, and max no more than 300. My markers are sorted in an array. What should I go with?


I'm not entirely sure I understand your question but hopefully I can help.

I am presuming this is part of a larger website with an existing db behind it so it sounds to me that you should store your markers in the db and read the required markers out when the page is requested. Your business logic will make sure you get the correct markers at any given time. Your view can then take an IEnumerable which you can use to populate your map.

Your Marker class can look something like this

public class Marker
{
    public decimal Longitude { get; set;}
    public decimal Latitude { get; set;}
    //...plus any additional info you want to add (maybe text for each marker)
}

You've probably already come across this but, if not, here is a good place to get info on using the google map api:

http://code.google.com/apis/ajax/playground/#markers_v3

Apologies if this is not helpful as I have had to make a few assumptions on what you are working with.


My understanding of XML is more of a data transport mechanism rather than storage. Typically I'd store everything in the database and use XML or JSON to move data around.

My approach would be to store all the relevant information in a database and have a script that receives a request (it can include parameters such as date, category, etc) and returns the relevant rows as JSON (thought this can be XML or any other format).

The JavaScript code would be composed of a function that generates the request based on user input (or whatever data you need to get) and once it receives passes the data to a second function that creates the markers and the infowindows if neede

jQuery becomes very handy. You can use %.ajax()or $.getJSON() to make the requests and work with the data you get from the database.

This might help: http://code.google.com/apis/maps/articles/phpsqlsearch.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜