SlideShare une entreprise Scribd logo
1  sur  15
Integration of Google
Maps in Rails
Application
Swati Jadhav
1
Gmap4rails Gem provides:
Multiple Maps
 Markers with easy customization
 Clusters
 Circles
 Polygons
 Polylines

What all you need at Model level?
Latitude, Longitude and gmaps4rails_address
 In model:


acts_as_gmappable :process_geocoding => false
def gmaps4rails_address
end


If your model do not have the latitude or
longitude as fields, then you can delegate it or
add instance methods.
Controller:

users = User.all
@json = users.to_gmaps4rails do |user, marker|
marker.infowindow render_to_string(
:partial => <partial_name>,
:locals => { <locals> })
marker.picture({ :picture => “<image-file-path>” } )
marker.json({ :id => user.id })
end
View:

= gmaps( "markers" => { data: @json })
Map Configuration:
detect_location: false
 center_on_user: false
(centers map on the location detected through the
browser )
 auto_zoom: true
 zoom : 1 (initial zoom. Set, 'auto_zoom' to false before
setting 'zoom' value. This enables the 'zoom' value to
overide the default.)
 maxZoom: null
 minZoom: null
 auto_adjust: true (adjust the map to the markers if set to
true)

Markers


Load map without markers
= gmaps("map_options" => { :center_latitude =>
latitude, :center_longitude => longitude,
"auto_zoom" => true })



With Markers:

= gmaps("map_options" => { :center_latitude =>
latitude, :center_longitude => longitude,
"auto_zoom" => true }, "markers" => { data:
json, options: marker_options })


Add markers with js using addMarkers()

Example:
var home_pin = [{picture:
"/assets/referral_engine/pins/home.png", width:
32, lat: "#{@practice.latitude}", lng:
"#{@practice.longitude}"}];
Gmaps.map.addMarkers(home_pin)
Cluster


Cluster attributes:

•

do_clustering : to cluster markers, default to false
clusterer_gridSize: the more the quicker but the less
precise, default to 50
clusterer_maxZoom: define at which zoom level
clusterer is disabled, default to 10

•
•

Example:
= gmaps("markers" => { data: json, options:
{clusterer_gridSize: 25, do_clustering: true,
clusterer_maxZoom: 20} })
Circles


Create circle:
attributes to pass: latitude, longitude, radius, stroke-color, fill-opacity

Example:
circle = [{lng: longitude, lat: latitude, radius: radius,
strokeColor: "#00bdce", fillOpacity: 0.15}].to_json
Gmaps.map.circles = JSON.parse(data.circle)
Gmaps.map.create_circles()


Clear existing circles:
Gmaps.map.clear_circles()
callback
Gmaps.map.callback = function(){
google.maps.event.addListenerOnce(Gmaps.map.s
erviceObject, 'idle', function(){
/ set zoom-level
var zoomLevel =
Gmaps.map.serviceObject.getZoom();
if (zoomLevel > 12) {
Gmaps.map.serviceObject.setZoom(12);
}})};
Issues:


Full zoom-out for single pin

•

Solution: on map-load check the zoom-level
and adjust accordingly using setZoom()

Display only latest for multiple locations at
same place
• Solution: create group of such locations and add
while creating info-window for that location
include the info of all those grouped locations

Integration of Google-map in Rails Application

Contenu connexe

Tendances

Introduction to MapKit
Introduction to MapKitIntroduction to MapKit
Introduction to MapKitRob C
 
Geolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applicationsGeolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applicationsIvano Malavolta
 
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthKeeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthGeoffrey Goetz
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIDr. Volkan OBAN
 
Geolocation and mapping using Google Maps services
Geolocation and mapping using Google Maps servicesGeolocation and mapping using Google Maps services
Geolocation and mapping using Google Maps servicesIvano Malavolta
 
ggplot2 extensions-ggtree.
ggplot2 extensions-ggtree.ggplot2 extensions-ggtree.
ggplot2 extensions-ggtree.Dr. Volkan OBAN
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
 
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...Dr. Volkan OBAN
 
[2015/2016] Geolocation and mapping
[2015/2016] Geolocation and mapping[2015/2016] Geolocation and mapping
[2015/2016] Geolocation and mappingIvano Malavolta
 
Grails : Ordr, Maps & Charts
Grails : Ordr, Maps & ChartsGrails : Ordr, Maps & Charts
Grails : Ordr, Maps & ChartsHenk Jurriens
 
Where20 2008 Ruby Tutorial
Where20 2008 Ruby TutorialWhere20 2008 Ruby Tutorial
Where20 2008 Ruby TutorialShoaib Burq
 
Mobile geolocation and mapping
Mobile geolocation and mappingMobile geolocation and mapping
Mobile geolocation and mappingIvano Malavolta
 
Python en la Plataforma ArcGIS
Python en la Plataforma ArcGISPython en la Plataforma ArcGIS
Python en la Plataforma ArcGISXander Bakker
 

Tendances (20)

Introduction to MapKit
Introduction to MapKitIntroduction to MapKit
Introduction to MapKit
 
3 a. hil climbing
3 a. hil climbing3 a. hil climbing
3 a. hil climbing
 
Geolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applicationsGeolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applications
 
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthKeeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
Geolocation and mapping using Google Maps services
Geolocation and mapping using Google Maps servicesGeolocation and mapping using Google Maps services
Geolocation and mapping using Google Maps services
 
ggplot2 extensions-ggtree.
ggplot2 extensions-ggtree.ggplot2 extensions-ggtree.
ggplot2 extensions-ggtree.
 
Swift Map
Swift MapSwift Map
Swift Map
 
py_AutoMapMaker
py_AutoMapMakerpy_AutoMapMaker
py_AutoMapMaker
 
Wikimapia mari kita jelaskan seluruh dunia!
Wikimapia   mari kita jelaskan seluruh dunia!Wikimapia   mari kita jelaskan seluruh dunia!
Wikimapia mari kita jelaskan seluruh dunia!
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...
 
Geolocation and Mapping
Geolocation and MappingGeolocation and Mapping
Geolocation and Mapping
 
Basic Calculus in R.
Basic Calculus in R. Basic Calculus in R.
Basic Calculus in R.
 
[2015/2016] Geolocation and mapping
[2015/2016] Geolocation and mapping[2015/2016] Geolocation and mapping
[2015/2016] Geolocation and mapping
 
Grails : Ordr, Maps & Charts
Grails : Ordr, Maps & ChartsGrails : Ordr, Maps & Charts
Grails : Ordr, Maps & Charts
 
Where20 2008 Ruby Tutorial
Where20 2008 Ruby TutorialWhere20 2008 Ruby Tutorial
Where20 2008 Ruby Tutorial
 
Mobile geolocation and mapping
Mobile geolocation and mappingMobile geolocation and mapping
Mobile geolocation and mapping
 
Python en la Plataforma ArcGIS
Python en la Plataforma ArcGISPython en la Plataforma ArcGIS
Python en la Plataforma ArcGIS
 
Geohex at Off4g2009
Geohex at Off4g2009Geohex at Off4g2009
Geohex at Off4g2009
 

En vedette

Participatory working in the U.K.
Participatory working in the U.K.Participatory working in the U.K.
Participatory working in the U.K.David Barrie
 
การทำ Flash popup menu v.2
การทำ Flash popup menu v.2การทำ Flash popup menu v.2
การทำ Flash popup menu v.2Augusts Programmer
 
Must Know Google Map Features for your Web application
Must Know Google Map Features  for your Web applicationMust Know Google Map Features  for your Web application
Must Know Google Map Features for your Web applicationAppsbee
 
Architecture at SimpleGeo: Staying Agile at Scale
Architecture at SimpleGeo: Staying Agile at ScaleArchitecture at SimpleGeo: Staying Agile at Scale
Architecture at SimpleGeo: Staying Agile at ScaleMike Malone
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsJonas Bonér
 

En vedette (6)

Planning for the Commonwealth’s Economic Rebound
Planning for the Commonwealth’s Economic Rebound Planning for the Commonwealth’s Economic Rebound
Planning for the Commonwealth’s Economic Rebound
 
Participatory working in the U.K.
Participatory working in the U.K.Participatory working in the U.K.
Participatory working in the U.K.
 
การทำ Flash popup menu v.2
การทำ Flash popup menu v.2การทำ Flash popup menu v.2
การทำ Flash popup menu v.2
 
Must Know Google Map Features for your Web application
Must Know Google Map Features  for your Web applicationMust Know Google Map Features  for your Web application
Must Know Google Map Features for your Web application
 
Architecture at SimpleGeo: Staying Agile at Scale
Architecture at SimpleGeo: Staying Agile at ScaleArchitecture at SimpleGeo: Staying Agile at Scale
Architecture at SimpleGeo: Staying Agile at Scale
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 

Similaire à Integration of Google-map in Rails Application

Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008xilinus
 
How Quick Can We Be? Data Visualization Techniques for Engineers.
How Quick Can We Be? Data Visualization Techniques for Engineers. How Quick Can We Be? Data Visualization Techniques for Engineers.
How Quick Can We Be? Data Visualization Techniques for Engineers. Avni Khatri
 
Adobe MAX 2009: Making Maps with Flash
Adobe MAX 2009: Making Maps with FlashAdobe MAX 2009: Making Maps with Flash
Adobe MAX 2009: Making Maps with FlashOssama Alami
 
Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)
Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)
Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)Ossama Alami
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece CoLab Athens
 
Dynamic Data Visualization With Chartkick
Dynamic Data Visualization With ChartkickDynamic Data Visualization With Chartkick
Dynamic Data Visualization With ChartkickDax Murray
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of usOSCON Byrum
 
Askayworkshop
AskayworkshopAskayworkshop
Askayworkshopsconnin
 
Introduction to GGVIS Visualization
Introduction to GGVIS VisualizationIntroduction to GGVIS Visualization
Introduction to GGVIS VisualizationHemantSingh311
 
ArcGIS API for Javascript Tutorial
ArcGIS API for Javascript TutorialArcGIS API for Javascript Tutorial
ArcGIS API for Javascript TutorialMohammed Mahmoud
 
Google Maps API - DevFest Karlsruhe
Google Maps API - DevFest Karlsruhe Google Maps API - DevFest Karlsruhe
Google Maps API - DevFest Karlsruhe Martin Kleppe
 
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map WidgetsESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map WidgetsAllan Glen
 

Similaire à Integration of Google-map in Rails Application (20)

Google Maps JS API
Google Maps JS APIGoogle Maps JS API
Google Maps JS API
 
Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008
 
Google Maps API 101
Google Maps API 101Google Maps API 101
Google Maps API 101
 
Google Maps Api
Google Maps ApiGoogle Maps Api
Google Maps Api
 
How Quick Can We Be? Data Visualization Techniques for Engineers.
How Quick Can We Be? Data Visualization Techniques for Engineers. How Quick Can We Be? Data Visualization Techniques for Engineers.
How Quick Can We Be? Data Visualization Techniques for Engineers.
 
Adobe MAX 2009: Making Maps with Flash
Adobe MAX 2009: Making Maps with FlashAdobe MAX 2009: Making Maps with Flash
Adobe MAX 2009: Making Maps with Flash
 
Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)
Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)
Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
 
Google charts
Google chartsGoogle charts
Google charts
 
Dynamic Data Visualization With Chartkick
Dynamic Data Visualization With ChartkickDynamic Data Visualization With Chartkick
Dynamic Data Visualization With Chartkick
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
 
Askayworkshop
AskayworkshopAskayworkshop
Askayworkshop
 
Introduction to GGVIS Visualization
Introduction to GGVIS VisualizationIntroduction to GGVIS Visualization
Introduction to GGVIS Visualization
 
ArcGIS API for Javascript Tutorial
ArcGIS API for Javascript TutorialArcGIS API for Javascript Tutorial
ArcGIS API for Javascript Tutorial
 
Google Maps API - DevFest Karlsruhe
Google Maps API - DevFest Karlsruhe Google Maps API - DevFest Karlsruhe
Google Maps API - DevFest Karlsruhe
 
51811680 open layers
51811680 open layers51811680 open layers
51811680 open layers
 
The 21st Century Harvard Map
The 21st Century Harvard MapThe 21st Century Harvard Map
The 21st Century Harvard Map
 
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map WidgetsESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
 
Why Grails?
Why Grails?Why Grails?
Why Grails?
 
Why Grails
Why GrailsWhy Grails
Why Grails
 

Dernier

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 

Dernier (20)

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Integration of Google-map in Rails Application

  • 1. Integration of Google Maps in Rails Application Swati Jadhav 1
  • 2. Gmap4rails Gem provides: Multiple Maps  Markers with easy customization  Clusters  Circles  Polygons  Polylines 
  • 3. What all you need at Model level? Latitude, Longitude and gmaps4rails_address  In model:  acts_as_gmappable :process_geocoding => false def gmaps4rails_address end  If your model do not have the latitude or longitude as fields, then you can delegate it or add instance methods.
  • 4. Controller: users = User.all @json = users.to_gmaps4rails do |user, marker| marker.infowindow render_to_string( :partial => <partial_name>, :locals => { <locals> }) marker.picture({ :picture => “<image-file-path>” } ) marker.json({ :id => user.id }) end View: = gmaps( "markers" => { data: @json })
  • 5. Map Configuration: detect_location: false  center_on_user: false (centers map on the location detected through the browser )  auto_zoom: true  zoom : 1 (initial zoom. Set, 'auto_zoom' to false before setting 'zoom' value. This enables the 'zoom' value to overide the default.)  maxZoom: null  minZoom: null  auto_adjust: true (adjust the map to the markers if set to true) 
  • 6. Markers  Load map without markers = gmaps("map_options" => { :center_latitude => latitude, :center_longitude => longitude, "auto_zoom" => true })  With Markers: = gmaps("map_options" => { :center_latitude => latitude, :center_longitude => longitude, "auto_zoom" => true }, "markers" => { data: json, options: marker_options })
  • 7.  Add markers with js using addMarkers() Example: var home_pin = [{picture: "/assets/referral_engine/pins/home.png", width: 32, lat: "#{@practice.latitude}", lng: "#{@practice.longitude}"}]; Gmaps.map.addMarkers(home_pin)
  • 8.
  • 9. Cluster  Cluster attributes: • do_clustering : to cluster markers, default to false clusterer_gridSize: the more the quicker but the less precise, default to 50 clusterer_maxZoom: define at which zoom level clusterer is disabled, default to 10 • • Example: = gmaps("markers" => { data: json, options: {clusterer_gridSize: 25, do_clustering: true, clusterer_maxZoom: 20} })
  • 10.
  • 11. Circles  Create circle: attributes to pass: latitude, longitude, radius, stroke-color, fill-opacity Example: circle = [{lng: longitude, lat: latitude, radius: radius, strokeColor: "#00bdce", fillOpacity: 0.15}].to_json Gmaps.map.circles = JSON.parse(data.circle) Gmaps.map.create_circles()  Clear existing circles: Gmaps.map.clear_circles()
  • 12.
  • 13. callback Gmaps.map.callback = function(){ google.maps.event.addListenerOnce(Gmaps.map.s erviceObject, 'idle', function(){ / set zoom-level var zoomLevel = Gmaps.map.serviceObject.getZoom(); if (zoomLevel > 12) { Gmaps.map.serviceObject.setZoom(12); }})};
  • 14. Issues:  Full zoom-out for single pin • Solution: on map-load check the zoom-level and adjust accordingly using setZoom() Display only latest for multiple locations at same place • Solution: create group of such locations and add while creating info-window for that location include the info of all those grouped locations 