Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Finished moving to Google Maps API v3

  • Loading branch information...
commit 4e502aecbdeb130e5e4a503dc086c34528848d59 1 parent ac2dc5d
@autarch autarch authored
View
3  share/css-source/03-vegguide.css
@@ -978,9 +978,8 @@ h2.comment-attribution, h3.comment-attribution {
}
.map-info {
- height: 15.5em;
margin-top: -3%;
- width: 30em;
+ min-width: 25em;
}
/* This is a hack to force content to stay inside the info window. Otherwise
View
54 share/js-source/VegGuide/GoogleMap.js
@@ -65,7 +65,7 @@ VegGuide.GoogleMap.prototype.addMarkers = function (points) {
DOM.Element.show(div);
}
- var marker = this._createMarker( ll, point, div );
+ var marker = this._createMarker( this.map, ll, point, div );
if ( point.info_div ) {
var show_link = $( "show-" + point.info_div );
@@ -74,8 +74,6 @@ VegGuide.GoogleMap.prototype.addMarkers = function (points) {
}
}
- this.map.addOverlay(marker);
-
if ( ! this.marker ) {
this.marker = marker;
}
@@ -83,16 +81,14 @@ VegGuide.GoogleMap.prototype.addMarkers = function (points) {
};
VegGuide.GoogleMap.prototype.showFirstInfoWindow = function () {
- GEvent.trigger( this.marker, "click" );
+ google.maps.event.trigger( this.marker, "click" );
};
VegGuide.GoogleMap._Icons = {};
VegGuide.GoogleMap._makeIcons = function () {
- var base_icon = new google.maps.Icon();
-
- base_icon.Size = new google.maps.Size( 29, 40 );
- base_icon.Anchor = new google.maps.Point( 15, 40 );
+ var size = new google.maps.Size( 29, 40 );
+ var anchor = new google.maps.Point( 15, 40 );
/* The first element in each pair is the key and the second is the
icon name. The keys are category ids, and things like "1.1"
@@ -150,11 +146,15 @@ VegGuide.GoogleMap._makeIcons = function () {
var name = icons[i][1];
var image_uri = "/images/map-icons/" + name + ".png";
- VegGuide.GoogleMap._Icons[key] = new google.maps.Icon( base_icon, image_uri );
+ VegGuide.GoogleMap._Icons[key] = {
+ anchor: anchor,
+ size: size,
+ url: image_uri
+ };
}
};
-VegGuide.GoogleMap.prototype._createMarker = function ( ll, point, div ) {
+VegGuide.GoogleMap.prototype._createMarker = function ( map, ll, point, div ) {
var marker;
if ( point.category_id && point.veg_level ) {
@@ -169,10 +169,10 @@ VegGuide.GoogleMap.prototype._createMarker = function ( ll, point, div ) {
}
}
- marker = new GMarker( ll, { icon: icon } );
+ marker = new google.maps.Marker( { position: ll, map: map, icon: icon } );
}
else {
- marker = new GMarker( ll, { title: point.title } );
+ marker = new google.maps.Marker( { position: ll, map: map, title: point.title } );
}
var self = this;
@@ -181,7 +181,26 @@ VegGuide.GoogleMap.prototype._createMarker = function ( ll, point, div ) {
var new_div = div.cloneNode(true);
new_div.id = "";
- marker.bindInfoWindow(new_div);
+ var infoWindow = new google.maps.InfoWindow(
+ {
+ content: new_div
+ }
+ );
+
+ var self = this;
+ google.maps.event.addListener(
+ marker,
+ "click",
+ function () {
+ if ( self.lastWindow ) {
+ self.lastWindow.close();
+ }
+
+ infoWindow.open( map, marker );
+
+ self.lastWindow = infoWindow;
+ }
+ );
}
return marker;
@@ -194,7 +213,7 @@ VegGuide.GoogleMap.prototype._instrumentShowLink = function ( link, marker ) {
link,
"click",
function (e) {
- GEvent.trigger( marker, "click" );
+ google.maps.event.trigger( marker, "click" );
e.preventDefault();
if ( e.stopPropogation ) {
@@ -204,13 +223,6 @@ VegGuide.GoogleMap.prototype._instrumentShowLink = function ( link, marker ) {
);
};
-VegGuide.GoogleMap.prototype.showDirectionsFromForm = function (form) {
- var directions = new GDirections( this.map, $("google-maps-directions-text") );
-
- var query = "from: " + form.elements["from"].value + " to: " + form.elements["to"].value;
- directions.load(query);
-};
-
DOM.Ready.onDOMDone( function () {
if ( window.GUnload ) {
DOM.Events.addListener(
View
2  share/mason/autohandler
@@ -48,7 +48,7 @@
</div>
% if ( $m->request_comp()->attr('load_google_maps')) {
-<script src="//maps.google.com/maps/api/js?key=AIzaSyA7K5Bs2OYmAswhB5hyvbbUe0JzUrPz8BU&sensor=false"
+<script src="//maps.google.com/maps/api/js?key=AIzaSyCRSl_9eYOSC324DPKw6-6bGSX6VPZtwp8&sensor=false"
type="text/javascript"></script>
% }
View
12 share/mason/entry/large-map
@@ -26,18 +26,6 @@ DOM.Ready.onDOMDone( function () {
<div class="map-info" id="map-entry-info" style="display: none">
<h2><% $vendor->name() | h %></h2>
<& /lib/format/address.mas, vendor => $vendor, address => $vendor->address_hash &>
-
-<%doc>
-It seems that with a Google map, it's not possible to use modern event
-listeners, since it seems that the map or the info window or something
-ends up eating the event.
-</%doc>
- <form action="#" method="post" id="directions-form" onsubmit="map.showDirectionsFromForm(this); return false">
- <label for="from">Directions from:</label>
- <input type="text" class="text short" name="from" id="from" />
- <input type="hidden" name="to" value="<% $address_for_directions | h %>" />
- </form>
-
</div>
</div>
View
2  share/mason/lib/google-map.mas
@@ -160,7 +160,7 @@ my ( $weighted_average, $total_ratings )
<h2><% $vendor->name() | h %></h2>
% unless ( $vendor->is_organization() ) {
- <span class="how-veg veg-level-<% $vendor->veg_level() %>"><% $vendor->veg_description() %></span>
+ <span class="how-veg veg-level-<% $vendor->veg_level() %>"><% $vendor->veg_description() %></span><br />
% }
% if ( @categories > 1 ) {
Please sign in to comment.
Something went wrong with that request. Please try again.