• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

How can I give a name to a marker on Google Maps?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there!

I’m trying to learn some new things with Javascript. This time with Google Maps.

I already created a script for searching for a place. When I click on search it shows me the place on Google Maps with a marker. The next thing I want to do is to give the marker a name by means of an input field  when I move with my cursor over it, just like this pic. This is what I’m trying to do.
I already tried some things but I can’t figure it out. As you can see in my script I tried some things with the variable ‘namemarker’.

index.html


main.js


I hope someone can help me, thank you in advance for the help!
 
Marshal
Posts: 67478
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's called an "Info Window" and you can look it up as such in the Google Maps API documentation.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
function initMap() {
 var uluru = {lat: 30.070923, lng: -95.5112095};
 var map = new google.maps.Map(document.getElementById('map'), {
   zoom: 17,
   center: uluru
 });
 var marker = new google.maps.Marker({
   position: uluru,
   map: map
 });
}
 
Bear Bibeault
Marshal
Posts: 67478
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does that address the OP's question? He already knows how to create a marker.
 
Do you pee on your compost? Does this tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic