简体   繁体   English

如何像在Foursquare上一样将LatLon转换为Px:提示地图

[英]How to convert LatLon to Px like on Foursquare: the Map of tips


I'm trying to achieve the same thing as foursquare's tip of map 我正在尝试实现与Foursquare的地图提示相同的功能 在此处输入图片说明 before asking let me explain the homework I did and how I got stucked. 在问之前让我解释一下我做的作业以及如何卡住。 The idea behind this was to put a map with a layer with a certain color, then move the image below to the position of the marker. 其背后的想法是放置带有特定颜色图层的地图,然后将下面的图像移动到标记的位置。

在此处输入图片说明

My questions are, how do you get the absolute position of the marker in px, in order to move the second image to the exact center of the marker? 我的问题是,如何获取以px为单位的标记的绝对位置,以便将第二个图像移到标记的确切中心?

I still don't have a huge traffic so, I'll stick to Googlemaps, but how do you scroll inside the map in google maps, is it achievable in google maps? 我仍然流量不大,所以我会坚持使用Googlemaps,但是您如何在Google Maps中滚动地图,在Google Maps中可以实现吗? or is it exclusive to openmaps? 还是openmap独有的?

IMHO You can simply use combination of CSS to do it: http://jsfiddle.net/fkw5xfov/3/ 恕我直言,您可以简单地使用CSS组合: http//jsfiddle.net/fkw5xfov/3/

在此处输入图片说明

Clue is here: 线索在这里:

#shadow {
    position: relative;
    left: -1950px;
    top: -1950px;
    height: 100px;
    width: 100px;
    border-radius: 50%;
    border: 2000px rgba(0,0,0,.4) solid; 
}

So to explain it: 所以要解释一下:

I created div with border-radius: 50% - nice & useful, then I add big border with rgba() color and at end I positioned it with position relative. 我用border-radius: 50%创建了div border-radius: 50% -很好且有用,然后我添加了带有rgba()颜色的大边框,最后我将其定位为相对位置。

It's importand to get this shadow layer inside other div which limit any strange sceolling & positioning effects 重要的是要在其他div内放置此shadow层,以限制任何奇怪的遮挡和定位效果

Of course as a background You can have anything. 当然作为背景,您可以拥有任何东西。 It can be image, a google maps div container etc. Rules are the same and You have to mostly remember about how each of containers is positioned. 它可以是图像,也可以是Google Maps div容器等。规则是相同的,并且您必须主要记住每个容器的放置方式。

And about converting LatLon position to Px here is a good article 关于将LatLon位置转换为Px,这是一篇不错的文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM