Remove hotels from overlay

7,168 views
Skip to first unread message

bigfoot2

unread,
Aug 29, 2011, 1:06:12 PM8/29/11
to google-map...@googlegroups.com
Hi, I have an apartment rentals website with a google map, the problem is that the map also shows the location of hotels (i think in an overlay as it loads a split second after the map loads) how do i remove the hotels?

Barry Hunter

unread,
Aug 29, 2011, 3:59:59 PM8/29/11
to google-map...@googlegroups.com
You can style the map
http://code.google.com/apis/maps/documentation/javascript/styling.html

Via a style can hide such poi.

(the wizard linked on that page, is a good way to interactivly get the
style you want)

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/uOOm6WZlQ4cJ.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

bigfoot1

unread,
Aug 29, 2011, 10:09:04 PM8/29/11
to google-map...@googlegroups.com
thanks I found thatm but am not sure to write I need. I have this:



<script type="text/javascript"
           
src="http://maps.google.com/maps/api/js?sensor=false">
           
</script>
           
<script type="text/javascript">
           
function initialize() {
           
var myProperty = new google.maps.LatLng(-41.13495,-71.313466);
           
var myLatlng = new google.maps.LatLng(-41.13495,-71.313466)
           
var myOptions={scrollwheel: false,
            zoom
: 16,
            center
: myLatlng,
            mapTypeId
: google.maps.MapTypeId.ROADMAP
           
}  

           
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

           
var marker = new google.maps.Marker({
            position
: myProperty,
            map
: map,
            icon
: 'http://www.rentalsbariloche.com/media/apartment.png',
                          clickable
: false,
                          title
:'Apartment One',
                          animation
: google.maps.Animation.DROP
           
});  
           
}
       
</script>

but think I have to add this somewhere??:

[
 
{
    featureType
: "poi.business",
    elementType
: "labels",
    stylers
: [
     
{ visibility: "off" }
   
]
 
}
]




Barry Hunter

unread,
Aug 31, 2011, 12:31:41 PM8/31/11
to google-map...@googlegroups.com
On Tue, Aug 30, 2011 at 3:09 AM, bigfoot1 <jezi...@gmail.com> wrote:
> thanks I found thatm but am not sure to write I need.

http://code.google.com/apis/maps/documentation/javascript/styling.html#styling_the_default_map

Add "styles" to the myOptions array, or use setOptions to set it seperately.

bigfoot1

unread,
Aug 31, 2011, 12:48:03 PM8/31/11
to google-map...@googlegroups.com
Thanks, but I'm still learning, I tried this but it still didn't work:

map.setOptions

Pil

unread,
Aug 31, 2011, 2:58:07 PM8/31/11
to Google Maps JavaScript API v3
Yes, it's a bit cumbersome, not very sophisticated and has many bugs.
It seems that you cannot compound featureType and elementType in this
way. It seems that every type needs it's own stylers property.
Have a look at this example how you can do it:

http://www.wolfpil.de/v3/labels.html

bigfoot1

unread,
Aug 31, 2011, 3:14:47 PM8/31/11
to google-map...@googlegroups.com
Thanks but also too complicated for me, I would not know how to remove the tickbox, nor change it so just the business layer is turned off......

I just want to know based on the following code that I already have, how to turn the business layer off and stop the hotels etc from appearing on my map...

<script type="text/javascript"
           
src="http://maps.google.com/maps/api/js?sensor=false">
           
</script>
           
<script type="text/javascript">
           
function initialize() {
           
var myProperty = new google.maps.LatLng(-41.13495,-71.313466);
           
var myLatlng = new google.maps.LatLng(-41.13495,-71.313466)
           
var myOptions={scrollwheel: false,
            zoom
: 16,
            center
: myLatlng,
            mapTypeId
: google.maps.MapTypeId.ROADMAP
           
}  

           
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

           
var marker = new google.maps.Marker({
            position
: myProperty,
            map
: map,

            icon
: 'media/apartment.png',

Pil

unread,
Aug 31, 2011, 3:36:21 PM8/31/11
to Google Maps JavaScript API v3
function turnOff() {
var mystuff = [];
var type = ["labels", "poi.business"];

for (var i = 0; i < type.length; i++) {
var style = {};
if (i == 0) {
style.elementType = type[i];
} else {
style.featureType = type[i];
}
style.stylers = [{visibility: 'off' }];
mystuff.push(style);
}
return mystuff;
}

map.setOptions({styles: turnOff() });

Thats mybe redudant because the labels may already include
poi.business.

bigfoot1

unread,
Aug 31, 2011, 4:15:40 PM8/31/11
to google-map...@googlegroups.com
thanks, but I added it to my script and it stopped the map from showing at all...

also looked very complicated....

here it is added to my script:


<script type="text/javascript"
            src="http://maps.google.com/maps/api/js?sensor=false">
            </script>
            <script type="text/javascript">
            function initialize() {
            var myProperty = new google.maps.LatLng(-41.13495,-71.313466);
            var myLatlng = new google.maps.LatLng(-41.13495,-71.313466)
            var myOptions={scrollwheel: false,
            zoom: 16,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
            }
           
            function turnOff() {
  var mystuff = [];
  var type = ["labels", "poi.business"];

  for (var i = 0; i <  type.length; i++) {
    var style = {};
    if (i == 0) {
    style.elementType = type[i];
    } else {
    style.featureType = type[i];
    }
    style.stylers = [{visibility: 'off' }];
    mystuff.push(style);
  }
  return mystuff;
}

map.setOptions({styles: turnOff() });

            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
           
            var marker = new google.maps.Marker({
            position: myProperty,
            map: map,
            icon: 'http://www.rentalsbariloche.com/media/apartment.png',

Barry Hunter

unread,
Aug 31, 2011, 5:24:52 PM8/31/11
to google-map...@googlegroups.com
You close, just need to give it the proper variable names like in the docs.

map.setOptions({styles: [


  {
    featureType: "poi.business",
    elementType: "labels",
    stylers: [
      { visibility: "off" }
    ]
  }

]});


Also you need to put it after you create the map. The link you showed
had it after.

There is absolutly no need for the complicated(ish) function that Pil showed

http://www.nearby.org.uk/google/temp/no-hotels1.php

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/google-maps-js-api-v3/-/Yk6ak13VsAsJ.

Barry Hunter

unread,
Aug 31, 2011, 5:30:06 PM8/31/11
to google-map...@googlegroups.com
But even better is just to add it your already existing mapOptions

http://www.nearby.org.uk/google/temp/no-hotels2.php

bigfoot1

unread,
Aug 31, 2011, 5:55:31 PM8/31/11
to google-map...@googlegroups.com
Thanks Barry, a clear, simple answer and a demo! awesome :)

Pil

unread,
Sep 1, 2011, 2:03:44 AM9/1/11
to Google Maps JavaScript API v3


On Aug 31, 11:30 pm, Barry Hunter <barrybhun...@gmail.com> wrote:
> But even better is just to add it your already existing mapOptions
>
> http://www.nearby.org.uk/google/temp/no-hotels2.php

Just to clarify: This example code turns off poi.business but it
doesn't turn off the labels.
The prolongation of my previous example is not just for fun.

Pil

unread,
Sep 1, 2011, 3:08:38 AM9/1/11
to Google Maps JavaScript API v3


On Aug 31, 11:24 pm, Barry Hunter <barrybhun...@gmail.com> wrote:
> You close, just need to give it the proper variable names like in the docs.
>
>  map.setOptions({styles: [
>    {
>      featureType: "poi.business",
>      elementType: "labels",
>      stylers: [
>        { visibility: "off" }
>      ]
>    }
>  ]});

Barry,

There is absolutly no need for complicating things more than
necessary.

The MapTypeStyleElementType specification 'labels' is no part or
subcategory of MapTypeStyleFeatureType specification 'poi'. So
'labels' is absolutely redundant and should not appear when you only
want to change 'poi' (or a subcategory of 'poi') - unless your
intention is confusion.

To turn 'poi.business' off - without the 'labels' - this should be
sufficient (and in fact it is):

map.setOptions({styles: [
{
featureType: "poi.business",
stylers: [
{ visibility: "off" }
]
}
]});


Barry Hunter

unread,
Sep 1, 2011, 7:54:36 AM9/1/11
to google-map...@googlegroups.com
On Thu, Sep 1, 2011 at 7:03 AM, Pil <wol...@gmail.com> wrote:
>
>
> On Aug 31, 11:30 pm, Barry Hunter <barrybhun...@gmail.com> wrote:
>> But even better is just to add it your already existing mapOptions
>>
>> http://www.nearby.org.uk/google/temp/no-hotels2.php
>
> Just to clarify: This example code turns off poi.business but it
> doesn't turn off the labels.

Who said anything about wanting to turn off labels anyway? Wasnt in
bigfoot1's question.


> The prolongation of my previous example is not just for fun.
>

> --
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.

Barry Hunter

unread,
Sep 1, 2011, 8:04:56 AM9/1/11
to google-map...@googlegroups.com
On Thu, Sep 1, 2011 at 8:08 AM, Pil <wol...@gmail.com> wrote:
>
>
> On Aug 31, 11:24 pm, Barry Hunter <barrybhun...@gmail.com> wrote:
>> You close, just need to give it the proper variable names like in the docs.
>>
>>  map.setOptions({styles: [
>>    {
>>      featureType: "poi.business",
>>      elementType: "labels",
>>      stylers: [
>>        { visibility: "off" }
>>      ]
>>    }
>>  ]});
>
> Barry,
>
> There is absolutly no need for complicating things more than
> necessary.
>
> The MapTypeStyleElementType specification 'labels' is no part or
> subcategory of MapTypeStyleFeatureType specification 'poi'. So
> 'labels' is absolutely redundant and should not appear when you only
> want to change 'poi' (or a subcategory of 'poi') - unless your
> intention is confusion.

Interesting argument (meta: is this a argument for the sake of an
argument?), but as we having this argument, often redundancy is used
deliberately. To be clear and unabigious about ones intentions etc. A
large percentage of semi-colons at the end of javascript lines are
redundant - but most coders supply them anyway.

Having elementType of labels just clarifies the intention, even
though the default of 'all' would encompass it too.

I didnt supply the actual style used anyway. bigfoot1 found it somewhere. :)

Pil

unread,
Sep 1, 2011, 9:31:33 AM9/1/11
to Google Maps JavaScript API v3
Barry,

be honest: Do you think that this line

elementType: "labels"

is needed when poi.business should be turned off?

Should it really be used altough it's not only redundant but does
something completely different when executed and therefore can only be
confusing (as it confused me)?




On Sep 1, 2:04 pm, Barry Hunter <barrybhun...@gmail.com> wrote:

Barry Hunter

unread,
Sep 1, 2011, 10:34:56 AM9/1/11
to google-map...@googlegroups.com
On Thu, Sep 1, 2011 at 2:31 PM, Pil <wol...@gmail.com> wrote:
> Barry,
>
> be honest: Do you think that this line
>
> elementType: "labels"
>
> is needed when poi.business should be turned off?

needed: no.

good to include anyway: yes.

>
> Should it really be used altough it's not only redundant but does
> something completely different when executed

Not to me it doesnt. Perhaps you using it wrong.

With it:
http://www.nearby.org.uk/google/temp/no-hotels2.php

Without it:
http://www.nearby.org.uk/google/temp/no-hotels22.php

Set to all
http://www.nearby.org.uk/google/temp/no-hotels23.php

All behave identical.

(You can test things like this easier using the styling wizard)

Pil

unread,
Sep 1, 2011, 11:05:46 AM9/1/11
to Google Maps JavaScript API v3

So when all examples are behaving identical it remains your secret why
it's "good to include anyway". Sorry, I cannot understand this
'logic'.

Look at my example above to see the difference when the 'labels' are
hidden and when the 'pois' are hidden.


On Sep 1, 4:34 pm, Barry Hunter <barrybhun...@gmail.com> wrote:
> On Thu, Sep 1, 2011 at 2:31 PM, Pil <wolf...@gmail.com> wrote:
> > Barry,
>
> > be honest: Do you think that this line
>
> > elementType: "labels"
>
> > is needed when poi.business should be turned off?
>
> needed: no.
>
> good to include anyway: yes.
>
>
>
> > Should it really be used altough it's not only redundant but does
> > something completely different when executed
>
> Not to me it doesnt. Perhaps you using it wrong.
>
> With it:http://www.nearby.org.uk/google/temp/no-hotels2.php
>
> Without it:http://www.nearby.org.uk/google/temp/no-hotels22.php
>
> Set to allhttp://www.nearby.org.uk/google/temp/no-hotels23.php

Barry Hunter

unread,
Sep 1, 2011, 11:29:10 AM9/1/11
to google-map...@googlegroups.com
On Thu, Sep 1, 2011 at 4:05 PM, Pil <wol...@gmail.com> wrote:
>
> So when all examples are behaving identical it remains your secret why
> it's "good to include anyway". Sorry, I cannot understand this
> 'logic'.

Not a secret. I guess just to me makes more sense (to me).

As much as anything its about predictablity.

Being as specific as posible - ie that just want to turn the
poi.business labels off. Is better than turning the whole of
poi.business. turning off the whole of poi.business off, might have
unpredictable results. We dont know.

Specifiy "exacly what want to do", rather than a broader "do all this"
just becauase it happens to do just that.

Say you have a single file in the folder. And you want to delete it.

* You could delete the folder. It would delete the file. And would
work just fine.

Now later, you add some more unrelated files to the folder (for what
ever reason).

Again you want to delete the single file, so you execute your "delete
folder" procedure. Result: the file has been deleted - good. (But so
have these other files - this is probably unintended. - bad)

So to delete the file, you delete the file - its safer. It more
robust. It jsut does what is intended.


>
> Look at my example above to see the difference when the 'labels' are
> hidden and when the 'pois' are hidden.

Yes, because [elementType: "labels"] - without a featureType is the
same as a [featureType: "all"] - ie it removes all labels from the map
- affects every single feature.

If you intending to remove all labels then fine.

Same as [featureType: "poi.business"] - without a elementType is the
same as a [elementType: "all"] - ie removes all business features -
effects all elements.

If you intending to all business data (ie the geometry too) then fine.
But be sure that is what you want to do.

>
>
> On Sep 1, 4:34 pm, Barry Hunter <barrybhun...@gmail.com> wrote:
>> On Thu, Sep 1, 2011 at 2:31 PM, Pil <wolf...@gmail.com> wrote:
>> > Barry,
>>
>> > be honest: Do you think that this line
>>
>> > elementType: "labels"
>>
>> > is needed when poi.business should be turned off?
>>
>> needed: no.
>>
>> good to include anyway: yes.
>>
>>
>>
>> > Should it really be used altough it's not only redundant but does
>> > something completely different when executed
>>
>> Not to me it doesnt. Perhaps you using it wrong.
>>
>> With it:http://www.nearby.org.uk/google/temp/no-hotels2.php
>>
>> Without it:http://www.nearby.org.uk/google/temp/no-hotels22.php
>>
>> Set to allhttp://www.nearby.org.uk/google/temp/no-hotels23.php
>>
>> All behave identical.
>>
>> (You can test things like this easier using the styling wizard)
>

> --
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.

Pil

unread,
Sep 1, 2011, 12:15:32 PM9/1/11
to Google Maps JavaScript API v3
Ok, I repeat the reasons why it's no good idea to include it in the
mentioned context:

1. It's intented for hiding the 'labels' of elementType category

2. It is redudant.

3. It leads to confusion.

4. It complicates things more than necessary.




On Sep 1, 5:29 pm, Barry Hunter <barrybhun...@gmail.com> wrote:

Barry Hunter

unread,
Sep 1, 2011, 1:53:56 PM9/1/11
to google-map...@googlegroups.com
On Thu, Sep 1, 2011 at 5:15 PM, Pil <wol...@gmail.com> wrote:
> Ok, I repeat the reasons why it's no good idea to include it in the
> mentioned context:
>
> 1. It's intented for hiding the 'labels' of elementType category

I dont understand what yo mean there.

As I see it, its for affecting the label "element"s, of what ever
featureType you (or dont) specify.

>
> 2. It is redudant.

Actully further to what I said before, seems I was wrong. Specifying
elementType: "labels" is acutlly different to "all" (or missing)

If you specify "labels", then you just hide labels. If you leave
elementType off altogether (or explictly say "all"() then you hiding
"geometry" too.

There arent many geometries attached to poi.business. But they do
exist. Look at new york city for example. there are a few. Use the
style wizard to toggle geometry on and off to see :)
(enter "loc: 40.734099,-73.945977" into the 'enter a location' box top right)

So leaving it off, has changed the meaning.

>
> 3. It leads to confusion.

Cant disagree there, given this conversation :)

>
> 4. It complicates things more than necessary.

Given the fact that it actully changes what is displayed, can only now
disagree.

So my answer would be "needed" - yes.

Pil

unread,
Sep 2, 2011, 5:41:47 AM9/2/11
to Google Maps JavaScript API v3
Ok, I concede that you may be right and it's needed. But this
necessity has consequences regarding the possibilities of what can be
done and what cannot be done with styled maps.

For convenience and that you know what I'm talking about I'll call
this necessity the type sophism. As I previously said styled maps are
not very sophisticated and have many bugs, it turns out that they are
even lesser sophisticated.

Let's assume I want to create a map where it is possible to toggle the
'labels' and to toggle a few subcategories of the 'pois' indepantently
from each other.

I've had serious problems to do that, and it didn't take long that I
found a further bug.

If you're interested you can read the report and play around with the
example
http://code.google.com/p/gmaps-api-issues/issues/detail?id=3587&sort=-id&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Internal%20Stars

Assumed that the type sophism exists then it turns out that this
intention is impossible.
(As I think now it's logically and syntactically impossible, i.e.
there is no possible unambiguous syntax to do that.)

What and where is the type sophism?

The layers consist of a series of overlays that are grouped into
different types. Some overlays belong to more than one type. However,
they are distinguishable by type categories.

The classification of elementType and featureType makes it possible to
distinguish these different layer groups and display them
indepantently from each other. But as soon as the classification
itself mingles the groups they are no more distinguishable.

And this is what the type sophism does. It assumes that each group
belongs in some way to the other. The API is no more able to assign
the types to the particular groups. Even the syntax makes it
impossible to distinguish the groups clearly.

As a consequence of the type sophism I also have to concede that the
workaround, which is mentioned in the bug report, is invalid and
cannot be replaced by a valid one, i.e. it is irreparable invalid,
because the API doesn't allow what I intended to do.

It's one more restriction to be added to many existing others.
Not sure if this was intended, though.




On Sep 1, 7:53 pm, Barry Hunter <barrybhun...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages