How to clear a specific layer (fusion layer) - google maps api v3 - google-maps

Here's the following problem:
I'm importing a fusion layer, which is queried by a list, works fine.
However, when I change the query, instead of just displaying the new results, it also displays the previous ones. I've tried different approaches, but none seems to work.
I would really be greatful for some insight

You should use
yourLayer.setMap(null);
to clear the map.
you can refer to the jsfiddle for clearing the traffic layer as reference.

Related

World vectorial map including states and cities map

I have a project (commercial) where i need a map with an overlay that i can click and have an action.
The main issue is that this map should be only the borders and the name of the locality, which from what i discovered neither google maps or other maps service offer.
Other sources of data like http://www.naturalearthdata.com/ are not very reliable because they miss a lot of information and usually they provide information only about a few countries.
Example: http://mtbo16.fpo.pt/mtbo/files/loc/loc_en.html
I need exactly the example from the url, except that i need to show only borders and names.
With Google Maps API you have an option to style the maps:
https://developers.google.com/maps/documentation/javascript/styling
So you can hide everything except locality names and borders on your map. Please have a look at this example: http://jsbin.com/nepode/edit?html,output
You can create your custom style using this wizard:
https://mapstyle.withgoogle.com/
Hope it helps!
You can take a look at this: http://vectormap.info/category/free_vector_maps_downloads/free_vector_world_maps/ what I did is the opposite, hide the map layers but you can have the option to show & you can change the background style, etc. I don't know, up to you just take a look, might be useful

fusion table map style/color inconsistencies

I have a Google fusion table that has a map based off a column of coordinates. The map and fusion table work fine for my application, but I'm noticing inconsistencies between the map view through Google fusion tables, and the map in my application which uses that exact fusion table. I'm wondering if anyone out there has had similar issues and if/how they alleviated them.
Inconsistencies:
Overlay color. The overlay color is set to green through the Google fusion table map view, but displays red in my map app, no matter what I change it to or how many times I change it.
Number Formatting: I've formatted the numbers to be displayed with
commas (123456 should be 123,456) through Google fusion tables UI. It is displaying like this when I view the column through the fusion table interface but it still displays it as 123456 in my application.
Google map pop out balloon. The pop-out balloon is not big enough for the text contained within it. So part of the text hangs off the bottom of the balloon. In some browsers/sessions it works fine, in others it hangs off the bottom.
Thank you for reading my question.
I also had run into your pop-out balloon overflow problem. Prior to today, I had just solved it by avoiding use of the <p> tags, favoring instead <br>. Today I searched for a separate solution which led me to an answer I think you'll get much benefit from: Tip: Use dynamic templating
I also ran into your first issue with overlay displaying as red. This is a baffling bug with fusion tables map styles. The only way I resolved it was by setting each style to default, then changing the overlay color to "static for all entries".
About number formatting. using the dynamic formatting link above, you can see that there's a way to deliver the formatted number, which uses a variable property of {$data.formatted.ColumnName}.
I hope that this answers all of your questions.
Ive found a solution to why the overlay colors are inconsistent and also why the pop-out boxes are not large enough for the containers:
You need to add "styleID" and "templateId" properties to the Fusion Tables Layer object:
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'Address',
from: 297050
},
map: map,
styleId: 1,
templateId: 2
});
The way to find what your ID's are is a little tricky. Open your fusion table, click on the "map" tab and click "publish" in the dropdown from the map tab. Copy that URL and paste it somewhere, look for something like this towards the end of the URL:
"y=2&tmplt=2"
the "y" is the styleID and the "tmplt" is the templateId.
I'm still working on the solution for the number formatting, thanks dwagPDX, im going to try your solution and let you know how that goes.
https://developers.google.com/fusiontables/docs/v1/using#WorkingStyles
https://groups.google.com/forum/#!topic/fusion-tables-users-group/EceabeRWqWc

Custom layer/overlay in google maps

Is it possible to create custom layers/overlays in google maps?
As an example, would it be possible to have one layer with polygons, another with circles, and a third with markers? and then hide/show these layers individually?
I tried looking at the documentation, but the layers seems to only be a fixed set of predefined layers. And overlays seems to only support image overlays.
Any help on this is appreciated.
I'm not sure if there exists a better way to do this, but I've found a workaround to a similar problem. My example utilizes markers and polylines, but it should be easy to extend the functionality to circles and polygons too.
Link to JSFiddle
Basically it works like this:
Initialize the map.
User selects an option what he would like to see on the map.
Click triggers a method (see HTML part of the fiddle) in the map object that first clears the map and then pushes new overlays on map.
The data that is currently shown on map is stored in arrays, and the map clearing method simply goes through these arrays and checks if there exists any content on map, and removes them if does.
Hope this helps. Cheers!

google maps markers

How do do i add them to my google map ? I've added the marker manager
<script src="http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js"></script>
And used the same syntax as in the documentation but they don't show up. The coordinates are correct . Can someone please dumb it down for me . Also does the zoom level have to be to a specific value for me to see them ?
For anyone else in trouble
http://code.google.com/apis/maps/documentation/javascript/examples/index.html
Andrei,
I found the Google Android MapView tutorial to be very helpful:
http://developer.android.com/guide/tutorials/views/hello-mapview.html
It covers creating a basic map application, as well as adding overlays to the MapView, and links to the directions for obtaining the necessary API key. Unfortunately (like a lot of Google's example code, apparently), there are a couple errors in the directions, but I was able to fix those fairly easily.
For example, the definition of your Overlay Class should be:
public class HelloItemizedOverlay extends ItemizedOverlay<OverlayItem>
Which not precisely what the directions say. Eclipse turns out to be very helpful in fixing the problems with this, though.
As to your question about zoom level, it has been my experience that all of your overlays will be displayed as long is your zoom level (or pan state) allows it. If you push them off the screen, they're not displayed, obviously, but not lost either.
R.

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.