마커 내부에 사용자 정의 HTML이있는 클릭 가능한 마커가있는 V3 API를 사용하여 Google 맵을 만드는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/1670202

문제

해당 위치의 주소와 사진으로 가득 찬 데이터베이스가 있습니다. 참고 : 위도 / 경도가 없습니다.

내가해야 할 일:

Google API v3을 사용하여 Google지도에 이러한 주소 중 일부를 나열하는 기능을 작성하여 마커를 클릭하면 데이터베이스에서 주소와 사진이 표시됩니다. 이것은 페이지의 플러그인이므로 헤더 데이터를 편집 할 수 없습니다. 표시되는 곳에 코드 만 삽입 할 수 있습니다.

나는 이미 문서를 읽었지만 모든 것이 불필요한 코드와 내 GeOMap이 필요하지 않은 것들이있는 것 같습니다. 원하는 경우 나중에 추가 할 수 있도록 가능한 가장 간단한 솔루션을 찾고 있습니다.

도움이 되었습니까?

해결책

여기에서 만든지도에서 빨간 마커를 클릭하십시오. http://www.dougglover.com/samples/uoitmap/index.html

당신이 찾고있는 것에 관한 것입니까?

다른 팁

아마도 당신은 gmapper를 시도하고 싶을 것입니다 (http://sourceforge.net/projects/gmapper/) Google지도를 수행하는 멋진 PHP 클래스. 모든 JavaScript를 생성하는 간단한 방법이며 주소를 찾을 수도 있습니다. Google은 주소 조회 수를 제한한다는 점에 유의하십시오. 하루에 DB를 검색 할 수 없을 것입니다.

사이트에서 당신을 지적 할 수 있습니까 (마커를 클릭하지 않고 마커를 떠날 때 업데이트를 제외하고는 코드를 호버 이벤트 대신 제공된 빈 클릭 이벤트로 이동하십시오). 진정한 코딩의 정신으로, 내가 한 일을 조정할 수 있기를 바랍니다!

http://www.primrose-house.co.uk/localattractions

    Here is the full html with google map api v3, markers will be create on dragging the route and then each marker having custom html inside the infowindow.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script type="text/javascript">
var rendererOptions = {
  draggable: true,
  suppressInfoWindows: true
  };
var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
var directionsService = new google.maps.DirectionsService();
var infowindow = new google.maps.InfoWindow();
var map;
var total;
var waypoint_markers = []

var myOptions = {
    zoom: 6,
    center: new google.maps.LatLng(46.87916, -3.32910),
    mapTypeId: 'terrain'
};
var markers = [];

function init() {
  map = new google.maps.Map(document.getElementById('map'),{'mapTypeId': google.maps.MapTypeId.ROADMAP});

  directionsDisplay.setMap(map);
  //directionsDisplay.setPanel($("#directionsPanel")[0]);

  google.maps.event.addListener(directionsDisplay, 'directions_changed', function() {
    watch_waypoints();
  });
  calcRoute(false);
}

function calcRoute(waypoints) {
  var selectedMode = "DRIVING"; //document.getElementById("mode").value;
  var ary;
  if(waypoints) {
    ary = waypoints.map(function(wpt) {return {location: wpt, stopover: false};});
  } else {
    ary = [];
  }

  var request = {
    origin: "Seattle, WA",
    destination: "Portland, OR",
    waypoints: ary,
    travelMode: google.maps.TravelMode[selectedMode],
    unitSystem: google.maps.UnitSystem["IMPERIAL"]
  };
  directionsService.route(request, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(response);
    }
  });
}

function watch_waypoints() {
  clear_markers();
  var wpts = directionsDisplay.directions.routes[0].legs[0].via_waypoints;
  for(var i=0; i<wpts.length; i++) {
    var marker = new google.maps.Marker({
        map: map,
        //icon: "/images/blue_dot.png",
        position: new google.maps.LatLng(wpts[i].lat(), wpts[i].lng()),
        title: i.toString(),
        draggable :true
        });
    waypoint_markers.push(marker);
    var infowindow = new google.maps.InfoWindow({ 
    content: "<table>" +
    "<tr><td>Waypoint:</td> <td><input type='text' id='name' value=''/> </td> </tr>" +
    "<tr><td>Waypoint Description:</td> <td><input type='text' id='address' value=''/></td> </tr>" +
    "<tr><td><input type='hidden' value='"+marker.getPosition()+"'id='hiddenval'></td></tr>"+
    "<tr><td></td><td><input type='button' value='Save & Close' onclick='saveData(<?php print_r(node_load(arg(1))->nid);?>)'/></td></tr>"
});
    google.maps.event.addListener(marker, 'click', function() {
        infowindow.open(map,marker);

    });
    google.maps.event.addListener(marker, 'dblclick', function() {
        marker.setMap(null);
        wpts.splice(parseInt(this.title), 1);
        calcRoute(wpts);
        directionsDisplay.setOptions({ preserveViewport: true, draggable: true});
    });
  }
}
function clear_markers() {
  for(var i=0; i<waypoint_markers.length; i++){
    waypoint_markers[i].setMap(null);
  }
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body onload="init()">
<div id="directionsPanel"></div>
<div id="map"></div>
</body>
</html>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top