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

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

Related

Best way to display 100k+ points on map

I have a dataset with several hundred thousand lat/long points. I would like to render these points on a map for info-graphic purposes (as small dots or something similar).
This is not something that necessarily has to be interactive, or rendered in a browser. It's okay if it's just an image.
I know that attempting this with markers and Google maps would be tough... any other tools out there that would generate this type of map? Preferably free/open source?
Or, do you have a method to make this work with something like Google maps? I don't want to use a marker clusterer... I need to be able to see all of the points.
In short :)
Download and fire-up Quantum GIS
Add some background map (e.g. OSM WMS layer from http://129.206.228.72/cached/osm)
Have your data in a CSV file, in WKT format, and load it on top (using add delimited text layer)
Save as image
You might want to peek what stackexchange.com has on GIS, too.

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.

Providing KML data in embedded Google Map, but how to hide the KML to the user

I've embedded google maps several times, only doing basic stuff though.
Now I need to overlay districts over a city. I worked hard to get, parse and adjust all the coordinates for all districts and I don't want others to copy my coordinates.
Can I display the overlays, but prevent users from reading the KML coordinates ? Is there a way to embed them other than having the path visible for everyone in the javascript api block ?
Try using a FusionTablesLayer. You can import your KML into a FusionTable, and prevent it from being downloaded, but display it on a map. People will be able to look at your coordinates, but it will be difficult (but probably not impossible) to grab them.

Google Maps v3 API: KML layer messing with click, mouse events

I'm working on a project where, after creating some nice code for creating polygons and attaching mouse events to them, the addition of KML layers (mainly placemarkers) results in uncooperative behaviour between the placeholders of the KML layer and the generated polygons.
If I create the polygons first and set the KML file afterwards, clicking on the placemarkers brings up the infowindow () as expected. However, mouseovers on the polygons below yield no result, whereas before they get highlighted and are clickable (which they aren't).
Setting the KML layer to null doesn't help either. The placemarkers disappear, but my polygons aren't registering.
When I first call the KML with placemarkers, the polygon layer called later goes on top of the placemarkers. The polygons are opaque, so you can see the placemarkers like you could through a window, but you can't click or interact with the placemarkers.
Setting the polygons to null results in the same behaviour as before. Placeholders still cannot be clicked on.
Help? I couldn't find a zIndex reference for the KML layer code, and I'm hoping that's all it is. I read somewhere else - and imagine this to be true - that the KML and user-gernated content "layers" are conflicting with one another - the latter one that's put on the map takes focus, captures events, etc. I would've thought that it wouldn't matter, in the same way that you can have divs on top of other divs, especially if you use indexing.
If you simply want to display the information in the KML layer and not have it react to user events, you can add the suppressInfoWindows flag to the constructor:
var myKmlLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml', { suppressInfoWindows: true });
This will effectively shut off all interactions and let your other layers receive interactions.
Edit: Forgot to mention that a good source of information is the Google API V3 site discussing KML layers

google maps api v2 - tens of thousands of markers

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.