Related to Google Map API error

Asked 2 years ago, Updated 2 years ago, 137 views

Hello. I am making a website using Google Maps API. It's nothing but I brought the Google map key and printed it out on the website It's going well without anyways An error message appears stating that creating an icon is a problem... I don't know why this problem is happening, so I'm asking this question.

//varmapLocation=newGoogle.maps.LatLng('33.381066', '126.536004'); // Location and longitude to be centered on the map
 16          
 17         var mapOptions = {
 15 varmapLocation = new google.maps.LatLng('33.381066', '126.536004'); // Location and longitude to be centered on the map
 16          
 17         var mapOptions = {
 18center: mapLocation, // the latitude and longitude to be centered on the map (variable)
 19 zoom: 10, // map zoom step
 20           mapTypeId: google.maps.MapTypeId.ROADMAP
 21         };
 22 varmap = new google.maps.map(document.getElementById("map-canvas")), // id: map-canvas, must equal the id of the div tag in body
 23             mapOptions);
 24          
 25 var size_x = 30; // Horizontal size of image to use as marker
 26 var size_y = 30; // Vertical size of image to use as marker
 27          
 28 // Image address to be used as marker
 29         var image = new google.maps.MarkerImage( 'http://www.larva.re.kr/home/img/boximage3.png',
 30                             new google.maps.Size(size_x, size_y),
 31                             '',
 32                             '',
 33                             new google.maps.Size(size_x, size_y));
 34 
 35         var restaurants = [] 
 36         <% @restaurants.each do |r| %>
 37           restaurants.push(["<%=r.name%>","<%=r.latitude%>","<%=r.longitude%>"])
 38         <% end %>
 39         
 40         var marker,i;
 41         var infowindow = new google.maps.InfoWindow();
 42 
 43         for(i=0;i<restaurants.length;i++){
 44           marker = new google.maps.Marker({
 45                position: new google.maps.LatLng(restaurants[i][1],restaurants[i][2]), 
 46                map: map,
 47 icon: image, // image to be used as marker (variable)
 48 title: title that appears when you touch the mouse point to the marker
 49           });

googlemap

2022-09-21 19:35

1 Answers

// Image address to be used as marker
 var image = new google.maps.MarkerImage( 'http://www.larva.re.kr/home/img/boximage3.png',
   new google.maps.Size(size_x, size_y),
     new google.maps.Point(0, 0),
     new google.maps.Point(0, 0),
   new google.maps.Size(size_x, size_y));

Or

var image = {
  url: 'http://www.larva.re.kr/home/img/boximage3.png',
  size:   new google.maps.Size(size_x, size_y),
  origin: new google.maps.Point(0, 0),
  anchor: google.maps.Point(0, 0),
  scaledSize:  google.maps.Size(size_x, size_y)
};

Try modifying it like this.


2022-09-21 19:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.