Tag: 地图

如何创build自定义MKAnnotationView和自定义注释标题和副标题

我需要在MKMapView上创build上面的Annotation视图。 我能够创build自定义注释视图,但在注释点击视图需要用大文本打开图像,我无法创build一个。 请给我提供一些链接或完成此任务的方法。

STL地图 – >按价值sorting?

我想知道如何实现STL地图按值sorting。 例如,我有一张地图m map<int, int>; m[1] = 10; m[2] = 5; m[4] = 6; m[6] = 1; 然后..我想分类与米的价值。 所以,如果我打印地图,我想要得到的结果 m[6] = 1 m[2] = 5 m[4] = 6 m[1] = 10 这个。 我怎么能这样sorting? 有没有什么办法可以处理与sorting值的关键和价值?

如何在地图的Annotation标注中添加自定义视图

这是我的代码我想添加我自己的自定义标注视图,而不是ios默认情况下,我知道只有leftCallout和右标注视图,但我需要添加一个视图工具提示types与我自己的背景和标签 – (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { MKAnnotationView *userAnnotationView = nil; if ([annotation isKindOfClass:MKUserLocation.class]) { userAnnotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"UserLocation"]; if (userAnnotationView == nil) { userAnnotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"UserLocation"]; } else userAnnotationView.annotation = annotation; userAnnotationView.enabled = YES; userAnnotationView.canShowCallout = YES; userAnnotationView.image = [UIImage imageNamed:@"map_pin.png"]; UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0,0,141,108)]; view.backgroundColor = [UIColor […]

显示Google Map Fragment中的当前位置

我目前正在研究一个带有Google Map的Fragment。 一旦用户访问该片段,他的地图应该放大并聚焦在他的位置上。 但是,它显示的是世界地图而不是附近的位置(靠近用户): @SuppressWarnings("unused") public class DeferredMapFragment extends MapFragment implements GoogleMap.OnCameraChangeListener, OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener { private static final String TAG = "DeferredMapFragment"; private Deque<Runnable> pendingActions; private AbstractMap<Marker, Object> tags; private GoogleMap map; private LocationRequest mLocationRequest; private GoogleApiClient mGoogleApiClient; private Location mLastLocation; private Marker marker; private GoogleMap.OnCameraChangeListener cameraChangeListener = null; private boolean isMapReady = […]

使用java地图进行范围search

我有一个用例,如果一个数字在0-10之间,它应该返回0,如果它介于11-20之间,它应该返回1等 0 => 0-3, (0 and 3 are inclusive) 1 => 4-15, (4 and 15 are inclusive) 2 => 16-40, (16 and 40 are inclusive) 3 => 41-88, (41 and 88 are inclusive) 5 => 89-300 (89 and 300 are inclusive) 我在想如何实现和思考java地图,但它不允许范围search 我对这样的事情感兴趣,我有一个function int foo() { } 如果foo返回5,因为它介于0到10之间,我会使用0,如果foo返回25,它将使用2。 有任何想法吗 编辑:实际上,范围并不像0-10,11-20那么简单。 我希望能够做范围search。 对于混淆抱歉。 根据查询,我添加了正确的例子,数字是连续的

两个纬度和经度之间的中点

我试图将这个http://www.movable-type.co.uk/scripts/latlong.html中给出的代码片段转换为java。 但我没有得到与网站相同的结果。 这里是我的代码来find两个点之间的中点,其中纬度和经度给予 midPoint(12.870672,77.658964,12.974831,77.60935); public static void midPoint(double lat1,double lon1,double lat2,double lon2) { double dLon = Math.toRadians(lon2-lon1); double Bx = Math.cos(lat2) * Math.cos(dLon); double By = Math.cos(lat2) * Math.sin(dLon); double lat3 = Math.atan2(Math.sin(lat1)+Math.sin(lat2),Math.sqrt( (Math.cos(lat1)+Bx)*(Math.cos(lat1)+Bx) + By*By) ); double lon3 = lon1 + Math.atan2(By, Math.cos(lat1) + Bx); System.out.print(lat3 +" " + lon3 ); } 我不确定这个dLon是否正确。 所以请帮助我们弄清楚。 […]

访问地图中的最后一个条目

如何将一个特定的HashMap条目移动到最后的位置? 例如,我有这样的HashMap值: HashMap<String,Integer> map = new HashMap<String,Integer>(); map= {Not-Specified 1, test 2, testtest 3}; “不明确”可能会出现在任何位置。 它可能会先出现在地图的中间。 但是我想把“未指定”移到最后的位置。 我怎样才能做到这一点? 提前致谢。

Google地图API – 获取最接近的邮政编码

首先,感谢您花时间考虑我的问题和您的帮助。 我正在使用Google Maps API v3和JavaScript将地图添加到网站。 我有一个地址列表,并成功地绘制在地图上。 当用户input一个邮政编码时,地图重新显示他们的位置,显示最接近该点的标记。 现在,我需要创build一个最近的3或5个位置的列表视图到他们的邮政编码与驱动方向的链接。 我被卡住了…并打开build议。 谢谢!

remove_if相当于std :: map

我试图根据特定的条件从地图中删除一系列元素。 我如何使用STLalgorithm做到这一点? 最初我想过使用remove_if但是这是不可能的,因为remove_if不适用于关联容器。 有没有任何“remove_if”等效algorithm适用于map? 作为一个简单的选项,我想通过循环地图和擦除。 但是通过地图循环并擦除一个安全的选项?(因为迭代器在擦除后变得无效) 我用下面的例子: bool predicate(const std::pair<int,std::string>& x) { return x.first > 2; } int main(void) { std::map<int, std::string> aMap; aMap[2] = "two"; aMap[3] = "three"; aMap[4] = "four"; aMap[5] = "five"; aMap[6] = "six"; // does not work, an error // std::remove_if(aMap.begin(), aMap.end(), predicate); std::map<int, std::string>::iterator iter = aMap.begin(); std::map<int, std::string>::iterator […]

为什么在使用时C ++映射types参数需要一个空的构造函数?

另请参阅C ++标准列表和缺省构造types 不是一个主要的问题,只是烦恼,因为我不希望我的课没有特定的参数实例化。 class MyClass { public: MyClass(MyType1 t); MyType2 &operator[](int index); } map<int, MyClass> myMap; 这给了我以下的g ++错误: /usr/include/c++/4.3/bits/stl_map.h:419:错误:没有匹配函数调用'MyClass()' 这编译罚款,如果我添加一个默认的构造函数; 我确定它不是由不正确的语法造成的。