本文整理汇总了PHP中Map::addMarker方法的典型用法代码示例。如果您正苦于以下问题:PHP Map::addMarker方法的具体用法?PHP Map::addMarker怎么用?PHP Map::addMarker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::addMarker方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCoord
$org = getCoord($finarr[$i]);
//echo $org[0]['latitude'];
//echo $org[0]['longitude'];
$des = array();
$des = getCoord($finarr[$i + 1]);
//echo $des[0]['latitude'];
//echo $des[0]['longitude'];
//creating marker
$marker = new Marker();
$marker->setPrefixJavascriptVariable('marker_');
$marker->setPosition($org[0]['latitude'], $org[0]['longitude'], true);
$marker->setAnimation(Animation::DROP);
$marker->setOption('clickable', true);
$marker->setOption('flat', true);
$marker->setOptions(array('clickable' => true, 'flat' => true));
$map->addMarker($marker);
$marker2 = new Marker();
$marker2->setPrefixJavascriptVariable('marker_two');
$marker2->setPosition($des[0]['latitude'], $des[0]['longitude'], true);
$marker2->setAnimation(Animation::DROP);
$marker2->setOption('clickable', true);
$marker2->setOption('flat', true);
$marker2->setOptions(array('clickable' => true, 'flat' => true));
$map->addMarker($marker2);
// trying directions
$directions = new Directions(new CurlHttpAdapter());
$request = new DirectionsRequest();
// Set your origin
$request->setOrigin($marker->getPosition(), true);
// Set your destination
$request->setDestination($marker2->getPosition(), true);
示例2: getMarker2
function getMarker2($orglat, $orglong, $deslat, $deslong)
{
//creating map
$map = new Map();
$map->setPrefixJavascriptVariable('map_');
$map->setHtmlContainerId('map_canvas');
$map->setAsync(false);
$map->setAutoZoom(false);
$map->setCenter(37.806381, -122.415468, true);
$map->setMapOption('zoom', 16);
$map->setBound(-2.1, -3.9, 2.6, 1.4, true, true);
$map->setMapOption('mapTypeId', MapTypeId::ROADMAP);
$map->setMapOption('mapTypeId', 'roadmap');
$map->setMapOption('disableDefaultUI', true);
$map->setMapOption('disableDoubleClickZoom', true);
$map->setMapOptions(array('disableDefaultUI' => true, 'disableDoubleClickZoom' => true));
$map->setStylesheetOption('width', '600px');
$map->setStylesheetOption('height', '600px');
$map->setStylesheetOptions(array('width' => '1000px', 'height' => '800px'));
$map->setLanguage('en');
//creating marker
$marker3 = new Marker();
$marker3->setPrefixJavascriptVariable('marker_');
$marker3->setPosition($orglat, $orglong, true);
$marker3->setAnimation(Animation::DROP);
$marker3->setOption('clickable', true);
$marker3->setOption('flat', true);
$marker3->setOptions(array('clickable' => true, 'flat' => true));
$map->addMarker($marker);
$marker4 = new Marker();
$marker4->setPrefixJavascriptVariable('marker_two');
$marker4->setPosition($deslat, $deslong, true);
$marker4->setAnimation(Animation::DROP);
$marker4->setOption('clickable', true);
$marker4->setOption('flat', true);
$marker4->setOptions(array('clickable' => true, 'flat' => true));
$map->addMarker($marker4);
// trying directions
$directions = new Directions(new CurlHttpAdapter());
$request = new DirectionsRequest();
// Set your origin
$request->setOrigin($marker3->getPosition(), true);
// Set your destination
$request->setDestination($marker4->getPosition(), true);
$response = $directions->route($request);
// Get the routes
$routes = $response->getRoutes();
// Iterate each routes
foreach ($routes as $route) {
// Get the bound
$bound = $route->getBound();
// Get the copyrights
$copyrights = $route->getCopyrights();
// Get the legs
$legs = $route->getLegs();
// Get the summary
//$summary = $route->getSummary();
//print_r ($summary);
foreach ($legs as $leg) {
// Gets the distance
$distance = $leg->getDistance();
//$dist = (String)$distance;
print_r($distance);
// Gets the duration
$duration = $leg->getDuration();
print_r($duration);
//summary
//$summary = $leg->getSummary();
//print_r ($summary);
// Gets the directions steps.
$steps = $leg->getSteps();
// Iterate each step
foreach ($steps as $step) {
// Gets the encoded polyline.
$encodedPolyline = $step->getEncodedPolyline();
$map->addEncodedPolyline($encodedPolyline);
}
}
}
// end of 1st iteration. found time and distance
//printing the map
$mapHelper = new MapHelper();
echo $mapHelper->renderHtmlContainer($map);
echo $mapHelper->renderJavascripts($map);
}