マーカー内にカスタム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はアドレスの検索数を制限することに注意してください。おそらく、1日で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