google maps api v2 - tens of thousands of markers - google-maps

my problem is with XXk (aka XX000) markers, atm I have 7k markers and will be more, and more, problem is in marker database, because atm this is 4MB (link to my DB http://tinyurl.com/ybau9ce) and problem is, how load that fast? for example DOWNLOAD only this what are show now, DOWNLOAD because load I have with ClusterMarker and problem is not with java but with download that database I think...

http://code.google.com/apis/maps/documentation/overlays.html
find the part about the marker manager
quote from that "The manager monitors the map's current viewport and zoom level, dynamically adding or removing markers from the map as they become active."
dynamicly doing this would require a database with all the markers.
Theres a good explanation on how to do that on the link under here.
code.google.com/apis/maps/articles/phpsqlajax.html
you are able then to dynamicly generate those markers that are in the boundaries of the current zoom.
There will be some events after zooming or moving the map and you can then trigger on that
and find out the boundaries of the current view.
Would that be helping solving it?

Why would you want to download all that data at once? You cannot visualize 7K markers at once on a map imo.
I don't know what the goal of your question is, but I would have only the data uploaded that is in focus, e.g. on display and visible.

Related

Create tiles given images and locations; convert markers to tiles

I've developed a HTML application that displays a map. This map has many fixed markers (they do not change in time).
Due to that:
I want to speed up the application
I want to hide the marker position from malicious users (so they can't use the information I've gathered for they're own porpose)
I want to convert the markers to a tile layer.
I've been googleing without success how to do this. Anyone has faced this problem and has a nice easy solution?
Thanks!
If the markers never change, there is a great solution:
Mapbox.
You can create your map with the markers, then the mapbox servors will send the tiles with the markers.
You can use a quadkey. It'similar to a quadtree. You can download my PHP class hilbert-curve # phpclasses.org. It also uses a quadkey.

Is it possible to add a Polygon layer to a google map v3 without using fusion tables

The question is pretty descriptive.
I am working on a website that provides locations for filming.
All the data in the site is currently stored in a MySQL database including geocode data for google maps.
I need to show polygon areas for the different london boroughs that has locations.
I have all the data as kml files, idealy i would like to store this in the MySQL database.
I have had success using fusion tables to display this data, but it seems silly to me to have to have this data duplicated on google just to use a fusion map layer, can i simply use a kml layer to render this data rather than having to create a fusion table and rendering it from that?
If so, is there a resource someone could point me to for more information?
UPDATE:
Thank you for the responses so far, i thought i would update the question with a little more info .
I eventually want to have all the areas displayed at the same time on my map and then when an area is clicked on ideally it would take you to another page on the website showing locations for that specific area.
I had initially tried using KML layers but i was getting errors saying my KML was invalid.
The KML was initially stored in a field in my database table, i think probably the errors were due to me not understanding exactly how google read in the KML data.
Using polygons would be far simpler to implement as i can get this data via JSON and then render the polygons from that.
I know now its not possible to have info windows with polygons, but i would just prefer to jump directly to another website page with info for that particular area using a click handler rather than show an info window.
Alternatively as suggested showing a tool-tip with a brief description of the area and a link to the page would be better, how the tooltip itself, is it possible to render on top the map?
I am slightly worried that I will reach the layer limit for the KML.
Is it possible to have multiple polygons rendered with KML on one layer, or do i need a separate layer for each clickable area?
The Google Maps API provides a pretty straightforward method to draw polygons.
Basic Example:
var polygon = new google.maps.Polygon({
map: your_google_map_instance,
paths: array_of_latlng_points,
fillColor: "#336699",
fillOpacity: .5,
})
EDIT: For this approach, you would need to parse your KML files (sorry, must've missed that when I first read it). You can import the KML files to a KML layer
You can overlay Polygons using KmlLayer, FusionTablesLayer (as you know), or native google.maps.Polygon objects.
KmlLayer and FusionTablesLayer render them as tiles, so for lots of Polygons (if you only need click events) will be more efficient. There are limitations on the number of KmlLayers that can be displayed on the map at one time and on FusionTablesLayer (but those don't seem to be causing you problems).
There are also third party parsers available for KML (geoxml3, geoxml-v3) which will take your KML and render it as native google.maps.Polygon objects. For lots of Polygons, this will be less efficient than tile based rendering, but it does allow mouseover/mouseout, and changing the properties of the Polygons dynamically.
You could also try data layers what have lots of events so you can display tooltips, info window, status text on various mouse events.
See samples in documentation:
https://developers.google.com/maps/documentation/javascript/datalayer
If you have many polygons (where the actual value of many depends on multiple factors, can be anywhere between 100 and 1,000) the best is to use a built in layer type. The fastest are the ones rendered on server, e.g. kml layer because this doesn't create hundreds of DOM elements in browser but still exposes click events so infoboxes can be displayed for each item.
In the worst case you can implement your own rendering with an image map, obviously by using an existing library like mapnik.
https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes

google maps v3 marker clustering without use of markerClusterer plugin or fusion or KML layers

Yes, I did research here and found so far only references to the MarkerClusterer plugin, or pointers to using KML or Fusion table layers.
This: https://developers.google.com/maps/articles/toomanymarkers#markermanager
was also an interesting read.
I'm thinking this should be relatively easy, no? Let me try to express what I'm doing in pseudo-code:
WILE event: "drag the map"
get current viewport bounds
load ajax call to look up markers that are located inside current viewport
remove previously visible markers
add newly visible markers to the display
END WHILE
I'm not that great at proper computer-science programming type stuff and struggle with the necessary structure for performing an efficient loopable action like this that continuously updates the marker array.
Somehow my gut feeling tells me this might be an inefficient way - should I approach this differently? What I'd like to avoid is updating the marker array on drag end.
Thanks for any help.
After some fiddling and further searching, the solution is buried here: google maps v3 duplicate markers - using an array to manage markers but still get duplicates

Large number of Google Map Markers and IE6?

I'm working on an application that generates a large number of Google Map markers (2000 - 7000) via JSON. I'm also using MarkerCluster. It works quick on Chrome and FF but IE6 takes few minutes and just crashes the first time I try to zoom in.
I'm not doing any more than just adding the markers to a map using JQuery & GMap API. So I looked at the following URL of the regular Google Map.
http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&q=hotel&sll=53.182996,-2.581787&sspn=1.494529,4.927368&ie=UTF8&split=1&rq=1&ev=p&hq=hotel&hnear=&ll=53.123702,-2.730103&spn=1.496594,4.927368&t=h&z=8
It shows a lot of tiny markers (~1000) and works fine on IE6. Do you have any ideas why this works and the markers added via the API struggles?
Thanks
Having thousands of markers coming out of your program does not sound like it is going to be very friendly for anyone with an older machine.
MarkerCluster doesn't actually reduce the number of markers on the map. It just groups them.
I would recommend implementing a clustering algorithm on the backend so that the number of markers to be shown on the map is reduced.

Google maps one placemark instead of many when zooming out

I have a google map with several placemarks, when you zoom out on it at some point several placemarks that are close, show as one, in the domain of the app this is a serious problem.
Is there anyway to show some sort of count or make obvious the fact that there are more than one placemark?
Cheers
MarkerClusterer was recently released on the GMaps Utility Library. It's the fastest client-side clusterer I've seen so far. There's a great example here which shows some of the options you can tweak.
This page compares and benchmarks some of the options available to you, and concludes that MarkerClusterer is the fastest.
Just keep in mind that if you have several thousand markers, any client-side solutions will probably be too slow.
There's an extension by Martin Pearman that addresses this situation:
ClusterMarker detects any groups of two or more markers whose icons visually intersect when displayed. Each group of intersecting markers is then replaced with a single cluster marker. The cluster marker, when clicked, simply centres and zooms the map in on the markers whose icons previously intersected.
There seems to be a problem with the redirection on Martin's page at the moment, but if you keep reloading it eventually works.