These are 2 different ways, you may try:
-
You can use Google Maps Reverse Geocoding . In result set you can determine whether it is water by checking
types
. In waters case the type isnatural_feature
. See more at this link http://code.google.com/apis/maps/documentation/geocoding/#Types.Also you need to check the names of features, if they contain
Sea, Lake, Ocean
and some other words related to waters for more accuracy. For example the deserts also arenatural_feature
s.Pros – All detection process will be done on client’s machine. No need of creating own server side service.
Cons – Very inaccurate and the chances you will get “none” at waters is very high.
-
You can detect waters/lands by pixels, by using Google Static Maps. But for this purpose you need to create http service.
These are steps your service must perform:
- Receive
latitude
,longitude
andcurrent zoom
from client. - Send
http://maps.googleapis.com/maps/api/staticmap?center={
latitude,
longitude}&zoom={
current zoom`}&size=1×1&maptype=roadmap&sensor=false request to Google Static Map service. - Detect pixel’s color of 1×1 static image.
- Respond an information about detection.
You can’t detect pixel’s color in client side. Yes , you can load static image on client’s machine and draw image on
canvas
element. But you can’t usegetImageData
of canvas’s context for getting pixel’s color. This is restricted by cross domain policy.Prons – Highly accurate detection
Cons – Use of own server resources for detection
- Receive