Google Maps - Longitude and latitude from database - More than 5000 entries

Hello All,

I am looking at the provided google maps extension and bit confused for using them for my scenario

I have a table with


Longitude, latitude , Count , Name 

Columns

and have data more than five thousand records . This count can be increased later …

I just want to display pointers on the displayed map from the database. If user drags the map right or left side I want to get display markers for the visual part of the map again from the database .

I don’t want to load all the markers at a time because of number of markers . How can I load markers from the database on demand … ( I mean on map drag …)

( Of course later on mark click I want to show Name and Count in the display box)

Please let me know if you have any example for this …

Thank You

Regards

YII FAN

You could do an ajax request when the map loads and after the user drags it, in the ajax request, include the NW and SE coordinates, and then do a query for all markers within that range, return the markers in json and insert them in the map.

Thank You @Wisp . Any sample or example for that . I am searching google for it, But couldn’t find a good resource . Again thanks for the suggestion

Regards

YII FAN

When you move/zoom the map, you cat get map bounds from the Google Maps API.

So you should know exactly which objects can be filtered.

I am not familiar with the Yii GMaps extension, but you can search for some events and bounds. :)

I’m also not familiar with the Yii GMaps extension, but here it is explained how you can get the bounds: http://stackoverflow.com/questions/3536175/google-maps-v3-getbounds-is-extending-beyond-what-is-visible-on-the-map?answertab=votes#tab-top

you need to send this coordinates using ajax to a page where you do the query and echo the results in json

here is an example for that: http://blog.sofasurfer.ch/2011/06/27/dynamic-google-map-markers-via-simple-json-file/

@BornToDrink - Thank You . I also just started playing with it.

@wisp - Thanks again for the links . I had a quick look at the links . The first one explains about boundaries and it is good . But the second one is not a dynamic loading of markers based on the view area . I will check again

THANK YOU

Regards

Yii Fan

You’ll have to do the coding yourself :D I don’t think a ready made example is available somewhere…

If you’ve done that you can post your solution here to help other users