【问题标题】:Google Map Api - Change color of the markersGoogle Map Api - 更改标记的颜色
【发布时间】:2015-12-10 17:41:06
【问题描述】:

我将 googleMapAPI.class.php 用于网站。

我的地址位于数据库中,我在地图上看到我的地址没有问题。

但是,标记是著名的红色,我想改变它!

你知道这是否可能吗?

我的页面代码是

<?php
//(1) On inclut la classe de Google Maps pour générer ensuite la carte.
require('GoogleMapAPI.class.php');

//(2) On crée une nouvelle carte; Ici, notre carte sera $map.
$map = new GoogleMapAPI('map');

//(3) On ajoute la clef de Google Maps.
$map->setAPIKey('njkhjkhjkhjkhkj');
    
//(4) On ajoute les caractéristiques que l'on désire à notre carte.
/*
$map->setWidth("800px");
$map->setHeight("500px");
$map->setCenterCoords ('2', '48');
$map->setZoomLevel (5);
$map->disableDirections();
*/

$map->SetWidth ('100%');
$map->SetHeight ('500px');
$map->setCenterCoords ('2', '48');
$map->setZoomLevel (5);
$map->setControlSize('small');
$map->disableTypeControls();
$map->setMapType('map');
$map->disableDirections();


// Connexion à la base de données
try {
    $bdd = new PDO('mysql:host=localhost:8889;dbname=DB;charset=utf8', 'user', 'pass');
}
catch(Exception $e) {
    die('Erreur : '.$e->getMessage());
}
 

$reponse = $bdd->query("SELECT * FROM Adresses");

 while ($donnees = $reponse->fetch())
 
{
$map->addMarkerByCoords(htmlspecialchars($donnees['GPSE']), $donnees['GPSN'] , "Maison", $donnees['Nom'], "<Appart>"); 

}
$reponse->closeCursor();

对于 api,我分享了链接,因为它太长了! Google Map Api class.php

你能帮我解决这个问题吗?

【问题讨论】:

    标签: api google-maps-markers


    【解决方案1】:

    添加图标时,请提供您希望用作下一个参数的图标的 URL:

    $map->addMarkerByCoords(
      htmlspecialchars($donnees['GPSE']),
      $donnees['GPSN'] ,
      "Maison",
      $donnees['Nom'],
      "<Appart>",
      "http://path/to/your/icon.gif"
    ); 
    

    【讨论】:

      猜你喜欢
      • 2013-05-11
      • 2014-04-04
      • 1970-01-01
      • 2021-09-22
      • 1970-01-01
      • 2020-05-03
      • 1970-01-01
      • 2019-09-18
      • 2012-12-23
      相关资源
      最近更新 更多