开发者

How to use google maps api to add markers based on certain conditions

Hey, Can someone help me with developing the following requirements?

I have a database that contains parking lot information. For easy interpretation assume that each parking lot has two attributes called id and address. Through a spring controller I'm passing a list of parking lots to a jsp page(displayAllPL.jsp) that contains the java script for google maps api in this fashion:

return new ModelAndView("/displayAllPL").addObject
            ("parkinglots", parkingLotList)

So doing something like this I can access each address in the jsp:

<c:forEach items="${parkinglots}" var="entry" varStatus="status">

${entry.address)

Requirement: I have to compare each of these parking lot addresses against the user's address(I get this address using geocoder in the google maps api) and find out which of those are within开发者_如何学Python 10 miles distance from the user's address. For all the parking lot addresses within 10 miles range, I need to add markers on the google map. Each of these marker should also contain a link to my controller that will display the parking lot information like shown below:

<a href="/<c:url value='/parkingstatus.html?plid=${entry.id }' />"/>

Any help is greatly appreciated as I totally suck at javascript. Thanks in advance.


First you have to geocode each of the parking lots and insert the lat/lng into the database (assuming youre using one). Then you use the haversine formula to search your database for parking lots within 10 miles. If you search this site for haversine youll find plenty of examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜