Change language

Python | Generating google map using gmplot package

Command to install gmplot :

 pip install gmplot 

Code # 1: to create a basemap

# import gmplot package

import gmplot

 
# GoogleMapPlotter returns a map object
# Pass in center latitude and
# center of longitude

gmap1 = gmplot.GoogleMapPlotter ( 30.3164945 ,

78.03219179999999 , 13 )

 
# Follow the absolute path

gmap1.draw ( "C: Users user Desktop map11.html" )

Output:

Code # 2: more one way to create a basemap

# gmplot package import

import gmplot

 
# from_geocode method returns
# latitude and longitude of this location.

gmap2 = gmplo t.GoogleMapPlotter.from_geocode ( "Dehradun, India" )

 

gmap2.draw ( "C: Users user Desktop map12.html " )

Output:

Code # 3: Scatter dots on a Google map and draw a line between them.

# import gmplot package

import gmplot

 

latitude_list = [ 30.3358376 , < / code> 30.307977 , 30.3216419 ]

longitude_list = [ 77.8701919 , 78.048457 , 78.0413095 ]

 

gmap3 = gmplot.GoogleMapPlotter ( 30.3164945 ,

78.03219179999999 , 13 )

 
# scatter method of the map object
# point spread on Google map

gmap3.scatter (latitude_list, longitude_list, ’# FF0000’ ,

size = 40 , marker = False )

 
# Line drawing method
# between the given coordinates
gmap3.plot (latitude_list, longitude_list, 

’cornflowerblue’ , edge_width = 2.5 )

 

gm ap3.draw ( "C: Users user Desktop map13.html" )

Output:

Code # 4: Show Heat Map Graph

# gmplot package import

import gmplot

 

latitude_list = [ 30.3358376 , 30.307977 , 30.3216419 , 30.3427904 ,

  30.378598 , 30.3548185 , 30.3345816 , 30.387299 ,

30.3272198 , 30.3840597 , 30.4158 , 30.340426 ,

30.3984348 , 30.3431313 , 30.273471 ]

  

longitude_list = [ 77.8701919 , 78.048457 , 78.0413095 , 77.886958 ,

77.825396 , 77.8460573 , 78.0537813 , 78.090614 ,

78.0355272 , 77.9311923 , 77.9663 , 77.952092 ,

78.0747887 , 77.955 5512 , 77.9997158 ]

 

gmap4 = gmplot.GoogleMapPlotter.from_geocode ( "Dehradun, India" )

 
# heat map Heating type
# dots on Google Map
gmap4.heatmap (latitude_list, longitude_list)

  

gmap4.draw ( "C: Users user Desktop map14.html" )

Output:

Code # 5: to drawing Place polygon on Google map

# import gmplot package

import gmplot

 

latitude_list = [ 30.3358376 , 30.307977 , 30.3216419 ]

longitude_list = [ 77.8701919 , 78.048457 , 78.0413095 ]

 

gmap5 = gmplot.GoogleMapPlotter ( 30.3164945 ,

78.03219179999999 , 13 )

  

gmap5.scatter (latitude_list, longitude_list, ’# FF0000’ ,

size = 40 , marker = False )

 
# polygon method Draw a polygon with
# coordinate help
gmap5.polygon (latitude_list, longitude_list,

color = ’cornflowerblue’ )

 

gmap5.draw ( "C: Users user Desktop map15.html " )

Output:

Shop

Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best laptop for development

$499+
Gifts for programmers

Best laptop for Cricut Maker

$299+
Gifts for programmers

Best laptop for hacking

$890
Gifts for programmers

Best laptop for Machine Learning

$699+
Gifts for programmers

Raspberry Pi robot kit

$150

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically